302869: CF556B. Case of Fake Numbers

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Case of Fake Numbers

题意翻译

机器人 Andrewid 是银河系著名的侦探。他现在正在调查一起欺诈案,这些欺诈者伪造了著名的斯托普齿轮,这些齿轮和魔方一样著名。 它最重要的部件是一个按钮和一系列类似的齿轮。每个齿轮都有 $n$ 齿,包含从 $0$ 到 $n-1$ 的所有数字,按逆时针顺序排列。按下按钮时,第一个齿轮顺时针旋转,第二个齿轮逆时针旋转,第三个齿轮顺时针旋转,依此类推。 此外,每个齿轮只有一个活动齿。当齿轮转动时,根据旋转方向,新的主动齿是当前主动齿之后的主动齿。例如,如果 $n=5$,且激活的齿是包含数字 $0$ 的齿,则顺时针旋转将激活数字 $1$ 的齿,或逆时针旋转将激活数字 $4$ 的齿。 Andrewid 记得,真正的拼图有以下特性:你可以多次按下按钮,这样最终齿轮主动齿上的数字从第一个到最后一个形成序列 $0,1,2,\cdots,n-1$。编写一个程序,确定给定的谜题是真是假。 第一行包含整数 $n(1\leq n\leq1000)$ 代表齿轮数。 第二行包含 $n$ 位数字 $a_1,a_2,\cdots,a_n$,代表主动齿序列:第 $i$ 个齿轮的主动齿包含编号 $a_i$。 如果给定 Stolp 的齿轮谜题是真的,则在输出 $\texttt{Yes}$,否则输出 $\texttt{No}$。 Translated By @hyc1026

题目描述

Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was. Its most important components are a button and a line of $ n $ similar gears. Each gear has $ n $ teeth containing all numbers from $ 0 $ to $ n-1 $ in the counter-clockwise order. When you push a button, the first gear rotates clockwise, then the second gear rotates counter-clockwise, the the third gear rotates clockwise an so on. Besides, each gear has exactly one active tooth. When a gear turns, a new active tooth is the one following after the current active tooth according to the direction of the rotation. For example, if $ n=5 $ , and the active tooth is the one containing number $ 0 $ , then clockwise rotation makes the tooth with number $ 1 $ active, or the counter-clockwise rotating makes the tooth number $ 4 $ active. Andrewid remembers that the real puzzle has the following property: you can push the button multiple times in such a way that in the end the numbers on the active teeth of the gears from first to last form sequence $ 0,1,2,...,n-1 $ . Write a program that determines whether the given puzzle is real or fake.

输入输出格式

输入格式


The first line contains integer $ n $ ( $ 1<=n<=1000 $ ) — the number of gears. The second line contains $ n $ digits $ a_{1},a_{2},...,a_{n} $ ( $ 0<=a_{i}<=n-1 $ ) — the sequence of active teeth: the active tooth of the $ i $ -th gear contains number $ a_{i} $ .

输出格式


In a single line print "Yes" (without the quotes), if the given Stolp's gears puzzle is real, and "No" (without the quotes) otherwise.

输入输出样例

输入样例 #1

3
1 0 0

输出样例 #1

Yes

输入样例 #2

5
4 2 1 4 3

输出样例 #2

Yes

输入样例 #3

4
0 2 3 1

输出样例 #3

No

说明

In the first sample test when you push the button for the first time, the sequence of active teeth will be 2 2 1, when you push it for the second time, you get 0 1 2.

Input

题意翻译

机器人 Andrewid 是银河系著名的侦探。他现在正在调查一起欺诈案,这些欺诈者伪造了著名的斯托普齿轮,这些齿轮和魔方一样著名。 它最重要的部件是一个按钮和一系列类似的齿轮。每个齿轮都有 $n$ 齿,包含从 $0$ 到 $n-1$ 的所有数字,按逆时针顺序排列。按下按钮时,第一个齿轮顺时针旋转,第二个齿轮逆时针旋转,第三个齿轮顺时针旋转,依此类推。 此外,每个齿轮只有一个活动齿。当齿轮转动时,根据旋转方向,新的主动齿是当前主动齿之后的主动齿。例如,如果 $n=5$,且激活的齿是包含数字 $0$ 的齿,则顺时针旋转将激活数字 $1$ 的齿,或逆时针旋转将激活数字 $4$ 的齿。 Andrewid 记得,真正的拼图有以下特性:你可以多次按下按钮,这样最终齿轮主动齿上的数字从第一个到最后一个形成序列 $0,1,2,\cdots,n-1$。编写一个程序,确定给定的谜题是真是假。 第一行包含整数 $n(1\leq n\leq1000)$ 代表齿轮数。 第二行包含 $n$ 位数字 $a_1,a_2,\cdots,a_n$,代表主动齿序列:第 $i$ 个齿轮的主动齿包含编号 $a_i$。 如果给定 Stolp 的齿轮谜题是真的,则在输出 $\texttt{Yes}$,否则输出 $\texttt{No}$。 Translated By @hyc1026

加入题单

算法标签: