cf C. Magic Formulas
http://codeforces.com/contest/424/problem/C
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define maxn 1000001
using namespace std; int f[maxn],n;
long long a[maxn];
void inti()
{
f[]=;
f[]=;
for(int i=; i<=maxn; i++)
{
f[i]=f[i-]^i;
}
}
int main()
{
inti();
scanf("%d",&n);
cin>>a[];
long long sum=a[];
for(int i=; i<n; i++)
{
cin>>a[i];
sum^=a[i];
}
for(int i=; i<n; i++)
{
if(i==) sum^=;
else
{
int m1=n%(i+);
int m2=n/(i+);
if(m2%==)
{
if(m1==)
{
if(i+==n)
{
sum^=(f[i]^);
}
else
{
sum^=;
}
}
else
{
sum^=f[m1];
}
}
else
{
int m3=f[i]^;
if(m1==)
{
if(i+==n)
{
sum^=(f[i]^);
}
else
{
sum^=(f[i]^);
}
}
else
{
sum^=(f[m1]);
sum^=(f[i]^);
}
}
}
}
cout<<sum<<endl;
return ;
}
cf C. Magic Formulas的更多相关文章
- Codeforces 424 C. Magic Formulas
xor是满足交换律的,展开后发现仅仅要能高速求出 [1mod1....1modn],....,[nmod1...nmodn]的矩阵的xor即可了....然后找个规律 C. Magic Formulas ...
- CodeForce 424C Magic Formulas
这个题就是求出给的公式的结果. 仅仅要知道异或运算满足交换律跟结合律即可了.之后就是化简公式. #include<map> #include<string> #include& ...
- codeforce-424C. Magic Formulas(数学)
C. Magic Formulas time limit per test:2 seconds memory limit per test:256 megabytes input stan ...
- Codeforces Round #242 (Div. 2) C. Magic Formulas
解题思路是: Q=q1^q2.......^qn = p1^p2......^pn^((1%1)^....(1%n))^((2%1)^......(2%n))^.... 故Q的求解过程分成两部分 第一 ...
- Codeforces Round #242 (Div. 2) C. Magic Formulas (位异或性质 找规律)
题目 比赛的时候找出规律了,但是找的有点慢了,写代码的时候出了问题,也没交对,还掉分了.... 还是先总结一下位移或的性质吧: 1. 交换律 a ^ b = b ^ a 2. 结合律 (a^b) ^ ...
- Codeforce 424C Magic Formulas 找规律
题目链接:http://codeforces.com/contest/424/problem/C 题意:求Q值 思路:找规律 显然能够得到一个矩阵 把这个矩阵画出来就能发现一个横向的规律和一个主对角线 ...
- codeforces C. Magic Formulas 解题报告
题目链接:http://codeforces.com/problemset/problem/424/C 题目意思:给出 n 个数:p1, p2, ..., pn,定义: q1 = p1 ^ (1 mo ...
- Codeforces Round #242 (Div. 2) <A-D>
CF424 A. Squats 题目意思: 有n(n为偶数)个x和X,求最少的变换次数,使得X的个数为n/2,输出变换后的序列. 解题思路: 统计X的个数ans,和n/2比較,少了的话,须要把n/2- ...
- Codeforces 424C(异或)
Magic Formulas Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Subm ...
随机推荐
- linux 命令后台执行
我想把updatedb命令(用于重新建立整盘索引的命令)放在后台运行.因为我不想眼睁睁的看着机器建立索引,我还想编会儿程序呢: # updatedb & [1] 23336 注释:在所要执行的 ...
- JVM基础和调优(二)
主要讲述java虚拟机的内存体系结构 了解了JVM 的一些基础之后,我们来看看java虚拟机内存的体系结构,这个是理解JVM垃圾收集算法的前提,理解了内存结构我们才能够针对不同的部分根据我们的程序进行 ...
- 算法导论(第三版) Exercises4.2(求最大和子数组的算法优化过程)
4.1-1 如所有元素都为负,则返回所有元素中最大的负数. 4.1-2(暴力法求最大和子数组) struct subarray { int start, end, sum; }; void brute ...
- Centos 6.5中安装后不能打开emacs的问题
问题的发现过程: 安装了最新的centos版本后发现居然打不开emacs,然后在终端中输入emacs后还是不能打开,出现了下面的提示: emacs: error while loading share ...
- FreeBSD ipfw App配置Examples
Step # 1: Enabling IPFW Open /etc/rc.conf file # vi /etc/rc.conf Append following settings: firewall ...
- About Adultism and why things ar the way they are
About - Adultism About Adultism and why things ar the way they are In this page we will try to clari ...
- 设计模式--观察者(Observer)
GOF给出的定义: Define a one-to-many dependency between objects so that when one object changes state, all ...
- curl 学习
<?php // $username =13800138000; // $password =123456; // $sendto =13912345678; // $message = &qu ...
- (转)iOS7界面设计规范(13) - UI基础 - 与iOS的系统整合
突然就到了周日傍晚.你永远不会知道自己的生活在接下来的一周当中能够发生多少变化:各种不可预知性所带来的更多是快感还是焦虑与不安,冷暖自知.相比之下,白天工作当中那些需求列表与排期文档就显得那么可爱了, ...
- ibatis使用--SqlMapClient对象
SqlMapClient对象 这个对象是iBatis操作数据库的接口(执行CRUD等操作),它也可以执行事务管理等操作.这个类是我们使用iBATIS的最主要的类.它是线程安全的.通常,将它定义为单例. ...