B. Case of Fake Numbers

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/556/problem/B

Description

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.

Input

The first line contains integer n (1 ≤ n ≤ 1000) — the number of gears.

The second line contains n digits a1, a2, ..., an (0 ≤ ai ≤ n - 1) — the sequence of active teeth: the active tooth of the i-th gear contains number ai.

Output

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

Sample Input

3
1 0 0

Sample Output

Yes

HINT

题意

给n个齿轮,每按一下,这些齿轮都会转

奇数位和偶数位的转动方向不一样

最后问能不能变成0,1,2,3,4...n-1

题解:

假设第一位方向是+1,那么就实质上第一个数就确定了转多少下了

于是判一下就好了

代码

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef unsigned long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 2000001
#define mod 1000000007
#define eps 1e-9
int Num;
char CH[];
const int inf=0x3f3f3f3f;
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} //************************************************************************************** int main()
{
int n,d;
cin >> n >> d;
for(int i = ; i < n; ++i)
{
int a;
cin >> a;
if(i!=(a+d*(i&?:-)+n)%n)
{
cout << "No" << endl;
return ;
}
}
cout << "Yes" << endl;
}

Codeforces Round #310 (Div. 2) B. Case of Fake Numbers 水题的更多相关文章

  1. 构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers

    题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少 ...

  2. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  3. 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

    题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...

  4. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  5. Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 水题

    C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just re ...

  6. Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题

    A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  7. Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 水题

    A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summ ...

  8. Codeforces Round #371 (Div. 2) A. Meeting of Old Friends 水题

    A. Meeting of Old Friends 题目连接: http://codeforces.com/contest/714/problem/A Description Today an out ...

  9. Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

    B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...

随机推荐

  1. Google搜索的常用技巧

    个人搜索方案 1.选择合适的搜索词,一些行业术语或专家名字可以带来更加高质量的结果. 2.搜索词手动使用空格分隔,先进行第一次搜索,看搜索结果标题是否满足预期,如果不满足,采用更换关键词,添加关键词, ...

  2. 【LeetCode】14 - Longest Common Prefix

    Write a function to find the longest common prefix string amongst an array of strings. Solution: cla ...

  3. Building nginx from Sources(从源代码安装nginx)

    Building nginx from Sources(从源代码安装nginx) The build is configured using the configure command.  安装用配置 ...

  4. 基于vagrant工具在win7下免密登录linux

    一.SSH加密方式 SSH采用的是"非对称密钥系统",即耳熟能详的公钥私钥加密系统,其安全验证又分为两种级别. 1. 基于口令的安全验证 这种方式使用用户名密码进行联机登录,一般情 ...

  5. 拜托,这才是“Uber”的正确读法

    在美国,私家车主可以注册成为Uber司机,这对传统的出租车行业形成了很大的挑战,同时也让Uber始终处于舆论的风口浪尖. 7月14日,美国用车应用Uber正式宣布进入北京市场.在进入中国后,Uber选 ...

  6. jq 弹出窗口

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  7. shell变量定义

    http://blog.csdn.net/longxibendi/article/details/6125075 set - 读写变量语法:set varName ?value?描述:返回变量varN ...

  8. Oracle中INT、FLOAT、NUMBER区别

    Oracle里的int等于number(长度,0) float也类似,number要定义小数部分的位数,而float不用定义后边小数有几位  因为NUMBER要确定长度,后边确定小数位. 所以,如果不 ...

  9. spring mvc中的valid

    当你希望在spring mvc中直接校验表单参数时,你可以采用如下操作: 声明Validator的方式: 1.为每一个Controller声明一个Validator @Controller publi ...

  10. ActiveX控件

    什么是ActiveX控件:一个进程内服务器,支持多种的COM接口.(可以理解为,一个COM接口是一个纯抽象基类,你实现了它,并且它支持自注册,就是一个ActiveX控件了)可以把ActiveX控件看做 ...