Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

People in the Tomskaya region like magic formulas very much. You can see some of them below.

Imagine you are given a sequence of positive integer numbers p1p2, ..., pn. Lets write down some magic formulas:

Here, "mod" means the operation of taking the residue after dividing.

The expression  means applying the bitwise xor (excluding "OR") operation to integers x and y. The given operation exists in all modern programming languages. For example, in languages C++ and Java it is represented by "^", in Pascal — by "xor".

People in the Tomskaya region like magic formulas very much, but they don't like to calculate them! Therefore you are given the sequence p, calculate the value of Q.

Input

The first line of the input contains the only integer n (1 ≤ n ≤ 106). The next line contains n integers: p1, p2, ..., pn (0 ≤ pi ≤ 2·109).

Output

The only line of output should contain a single integer — the value of Q.

Sample Input

Input
3
1 2 3
Output
3

Source

Codeforces Round #242 (Div. 2)

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
typedef long long LL;
int a[],b[];
int main()
{
int i,j,t,len,n,s,ans;
while(scanf("%d",&n)!=EOF)
{
scanf("%d",&t);
ans=t;
for(i=;i<=n;i++)
{
scanf("%d",&t);
ans^=t;
}
b[]=;
for(i=;i<=n;i++)
{
b[i]=b[i-]^i;
int tmp=n/i;
if(tmp&)
ans^=b[i-];
if(n%i)
ans=ans^b[n%i];
}
printf("%d\n",ans);
}
return ;
}

Codeforces 424C(异或)的更多相关文章

  1. 『ZJOI2019 D2T2』语言

    ~~ 话说,本题考场想出三只\(log\)的暴力做法,被卡成暴力了.~~ 题目分析 首先考虑枚举每一个点,计算这个点可以和多少点进行交易. 将所有经过该点的路径\(s,t\)拿出,那么这些极远的\(s ...

  2. XOR and Favorite Number CodeForces - 617E -莫队-异或前缀和

    CodeForces - 617E 给n个数, m个询问, 每次询问问你[l, r]区间内有多少对(i, j), 使得a[i]^a[i+1]^......^a[j]结果为k.(注意 i ! =  j) ...

  3. Codeforces Round #539 (Div. 2) 异或 + dp

    https://codeforces.com/contest/1113/problem/C 题意 一个n个数字的数组a[],求有多少对l,r满足\(sum[l,mid]=sum[mid+1,r]\), ...

  4. Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset(01字典树求最大异或值)

    http://codeforces.com/contest/706/problem/D 题意:有多种操作,操作1为在字典中加入x这个数,操作2为从字典中删除x这个数,操作3为从字典中找出一个数使得与给 ...

  5. Codeforces Round #482 (Div. 2) : Kuro and GCD and XOR and SUM (寻找最大异或值)

    题目链接:http://codeforces.com/contest/979/problem/D 参考大神博客:https://www.cnblogs.com/kickit/p/9046953.htm ...

  6. Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)

    F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...

  7. Codeforces Round #340 (Div. 2) E. XOR and Favorite Number 【莫队算法 + 异或和前缀和的巧妙】

    任意门:http://codeforces.com/problemset/problem/617/E E. XOR and Favorite Number time limit per test 4 ...

  8. Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution —— 异或

    题目链接:http://codeforces.com/contest/742/problem/B B. Arpa's obvious problem and Mehrdad's terrible so ...

  9. Codeforces Round #539 (Div. 2) C. Sasha and a Bit of Relax(前缀异或和)

    转载自:https://blog.csdn.net/Charles_Zaqdt/article/details/87522917 题目链接:https://codeforces.com/contest ...

随机推荐

  1. CCNET配置文件配置工具

    当我们在使用CruiseControl.NET进行配置的时候,你会发现配置文件是个非常头痛的事,无从下手,下面我在google找了一个09年的工具,主要是针对CruiseControl.NET进行配置 ...

  2. phpstudy2016最新版本mysql无法使用innodb的问题解决

    这里顺便记录一下今天遇见的神奇问题,在使用官方最新版本的phpstudy中,其它组件一切正常,但是奇怪的发现mysql是无法开启innodb的,以下为最新的下载地址: http://www.phpst ...

  3. ajax提交特殊字符的处理

    前台页面用encodeURIComponent()这个js方法 rule=encodeURIComponent(rule);//对特殊字符编码 后台页面 java.net.URLDecoder url ...

  4. eclipse中使用git

    有的eclipse已经自带了Git了,就不用安装了.如果,想重新安装,可以先卸载GIT,卸载 不同eclipse卸载不一样: 1.在Eclipse中依次点击菜单"Help"-> ...

  5. Eigenvectors and eigenvalues

    http://setosa.io/ev/eigenvectors-and-eigenvalues/ Explained Visually Tweet  By Victor Powell and Lew ...

  6. Linux创建线程

    #include"stdio.h" #include"pthread.h" #include"unistd.h" ; void *creat ...

  7. Centos更换yum库镜像

    首先备份/etc/yum.repos.d/CentOS-Base.repo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-B ...

  8. Session超时处理

    1.web.xml 添加配置: <!-- session超时 --> <filter> <filter-name>sessionFilter</filter- ...

  9. NPOI在.net中的操作Excel

    1.读取 using (FileStream stream = new FileStream(@"c:\客户资料.xls", FileMode.Open, FileAccess.R ...

  10. C#常用函数--通用篇

    C#常用函数→通用篇转载地址→http://www.cnblogs.com/superfang/archive/2008/07/02/1233706.html以前我都是"原文地址" ...