题目链接:http://codeforces.com/contest/424/problem/C
题意:求Q值
思路:找规律
显然能够得到一个矩阵
把这个矩阵画出来就能发现一个横向的规律和一个主对角线方向的规律
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define goal 1000000
#define ll int
#define N 1000005
ll n, s;
ll a[N];
ll du[N];
int main(){
ll i, j, len;
while(~scanf("%d",&n)){
for(i=1;i<=n;i++)scanf("%d",&a[i]);
du[0] = 0;
for(i=1;i<=n;i++)du[i] = du[i-1]^i;
ll ans = a[1];
for(i=2;i<=n;i++)ans ^= a[i];
for(i=1;i<=n;i++){
ll siz = n/i;
if(siz&1)ans ^= du[i-1];
if(n%i) ans ^= du[n%i];
}
printf("%d\n",ans);
}
return 0;
}