http://codeforces.com/problemset/problem/556/B
解题思路:
1.数据范围1000,暴力模拟可过
2.题目说可以执行多次,我大胆执行1000次,找不到就认定它不可能满足条件
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[1005];
for(int i = 0;i < n;i++) {
a[i] = sc.nextInt();
}
boolean tag = true;
for(int i = 1;i <= 1000;i++) {
tag = true;
for(int j = 0;j < n;j++) {
if(a[j] != j)
tag = false;
if(j % 2 == 0) {
a[j] = (a[j] + 1) % n;
} else {
a[j] = (a[j] - 1 + n) % n;
}
}
if(tag == true) {
System.out.println("Yes");
break;
}
}
if(tag == false) {
System.out.println("No");
}
}
}