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 ...
随机推荐
- POJ1141 Brackets Sequence
Description Let us define a regular brackets sequence in the following way: 1. Empty sequence is a r ...
- DLUTOJ #1394 Magic Questions
传送门 Time Limit: 3 Sec Memory Limit: 128 MB Description Alice likes playing games. So she will take ...
- CentOS 6.5(6.4)安装过程图文教程
CentOS 6.4是最新的出的系统,这里分享下安装教程,有些设置大部分教程没出现过,特分享下,方便需要的朋友 1.首先,要有一张CentOS 6.4的安装介质,使用介质启动电脑出现如下界面 界面说明 ...
- 创建,增加,删除mysql表分区
1.测试添加分区和删除分区 ###添加删除range分区 (1)创建一个分区: CREATE TABLE titles ( emp_no INT NOT NULL, titl ...
- c++新特性与boost
<Boost程序库探秘——深度解析C++准标准库>之试读 前一阵子还看到一篇文章,说C#要重蹈C++的覆辙,这里说的C++的覆辙是什么呢?是指C++语言过于臃肿的功能特性,导致学习人员的流 ...
- WINDOWS渗透与提权总结(1)
旁站路径问题: 1.读网站配置. 2.用以下VBS: 01 On Error Resume Next 02 03 If (LCase(Right(WScript.Fullname, 11)) = ...
- linux init.d脚本编写模板
#!/bin/bash ### BEGIN INIT INFO # # Provides: location_server # Required-Start: $local_fs $remote_fs ...
- Linux创建线程
#include"stdio.h" #include"pthread.h" #include"unistd.h" ; void *creat ...
- iOS-AFN "Request failed: unacceptable content-type: text/plain"
今天使用AFN测试程序时,返回如下错误 这是由于AFN默认不支持http返回结果为"text/plain"这种类型所致. 解决办法: 找到AFN框架中的AFURLResponseS ...
- AndroidStudio-引用jar包及so文件
一.引用jar文件 1.将jar文件复制.粘贴到app的libs目录中: 2.右键点击jar文件,并点击弹出菜单中的"Add As Library",将jar文件作为类 ...