Codeforces Round #242 (Div. 2) C Magic Formulas

打个表,记录1到下标为止所有数的XOR值即可

 

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <string.h>
 4 using namespace std;
 5 int array[1000001];
 6 int main(){
 7     int cnt, i, j, k, t, n, num;
 8     int temp = 0;
 9     for(k = 0 ;k <= 1000000 ; k++){
10         temp ^= k;
11         array[k] = temp;
12     }
13     while(EOF != scanf("%d",&n)){
14         cnt = 0;
15         for(i = 1; i <= n; i++){
16             scanf("%d",&num);
17             cnt ^= num;
18         }
19         for(i = 1 ;i <= n; i++){
20             int tmp_q = n / i;
21             int tmp_w = n % i;
22             while(tmp_q--){
23                 cnt ^= array[i-1];
24             }
25             if(tmp_w)
26                 cnt ^= array[tmp_w];
27         }
28         printf("%d\n",cnt);
29     }
30     return 0;
31 }

 

转载于:https://www.cnblogs.com/wushuaiyi/p/3690039.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值