Codeforces 424C(异或)
| Time Limit: 2000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
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 p1, p2, ..., 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
3
1 2 3
3
Source
#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(异或)的更多相关文章
- 『ZJOI2019 D2T2』语言
~~ 话说,本题考场想出三只\(log\)的暴力做法,被卡成暴力了.~~ 题目分析 首先考虑枚举每一个点,计算这个点可以和多少点进行交易. 将所有经过该点的路径\(s,t\)拿出,那么这些极远的\(s ...
- XOR and Favorite Number CodeForces - 617E -莫队-异或前缀和
CodeForces - 617E 给n个数, m个询问, 每次询问问你[l, r]区间内有多少对(i, j), 使得a[i]^a[i+1]^......^a[j]结果为k.(注意 i ! = j) ...
- Codeforces Round #539 (Div. 2) 异或 + dp
https://codeforces.com/contest/1113/problem/C 题意 一个n个数字的数组a[],求有多少对l,r满足\(sum[l,mid]=sum[mid+1,r]\), ...
- Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset(01字典树求最大异或值)
http://codeforces.com/contest/706/problem/D 题意:有多种操作,操作1为在字典中加入x这个数,操作2为从字典中删除x这个数,操作3为从字典中找出一个数使得与给 ...
- 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 ...
- Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)
F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- BZOJ-1922 大陆争霸 多限制、分层图最短路 (堆+dijkstra)
1922: [Sdoi2010]大陆争霸 Time Limit: 10 Sec Memory Limit: 64 MB Submit: 1154 Solved: 478 [Submit][Status ...
- href="javascript:void(0)"
javascript:是伪协议,表示url的内容通过javascript执行.void(0)表示不作任何操作,这样会防止链接跳转到其他页面.这么做往往是为了保留链接的样式,但不让链接执行实际操作,具体 ...
- spring全注解项目
项目结构如下: spring配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=&q ...
- 用 AIML 开发人工智能聊天机器人
借助 Python 的 AIML 包,我们很容易实现人工智能聊天机器人.AIML 指的是 Artificial Intelligence Markup Language (人工智能标记语言),它不过是 ...
- xcode6.3插件失效
1.打开终端,输入以下代码:defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID 2.获取到DV ...
- 实现ajax
啊打发 <script type="text/javascript" src="js/jquery-1.8.3.min.js"></scrip ...
- Linq 中 表连接查询
public void Test(){ var query = from a in A join b in B on A.Id equals B.Id into c from d in c.Defau ...
- ASP.NTE 5 Target framework dnx451 and dnxcore50(转)原文:http://www.cnblogs.com/xishuai/p/aspnet5-target-framework-dnx451-and-dnxcore50.html
中文不知如何定义标题,所以干脆就直接贴出关键字,在 ASP.NTE 5 项目的 project.json 配置文件中,会有这样的定义: "frameworks": { " ...
- 小白科普之JavaScript的BOM模型
一.什么是BOM 1. BOM是browser object model的缩写,简称浏览器对象模型: 2. BOM提供了独立于内容而与浏览器窗口进行交互的对象,描述了与浏览器进行交互的方法和接口: 3 ...
- document.documentElement和document.body的区别
网页中获取滚动条卷去部分的高度,可以通过 document.body.scrollTop 来获取,比如使div跟着滚动条滚动: <div id="div" style=&qu ...