Hdu-5344 MZL's xor
2016-05-29 17:54
260 查看
[align=left]Problem Description[/align]
MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to know the xor of all (Ai+Aj)(1≤i,j≤n)
The xor of an array B is defined as B1
xor B2...xor
Bn
[align=left]Input[/align]
Multiple test cases, the first line contains an integer T(no more than 20), indicating the number of cases.
Each test case contains four integers:n,m,z,l
A1=0,Ai=(Ai−1∗m+z)
mod
l
1≤m,z,l≤5∗105,n=5∗105
[align=left]Output[/align]
For every test.print the answer.
[align=left]Sample Input[/align]
2
3 5 5 7
6 8 8 9
[align=left]Sample Output[/align]
14
16
[align=left]Author[/align]
SXYZ
[align=left]Source[/align]
2015 Multi-University Training Contest 5
[align=left]Recommend[/align]
wange2014
分析:超级水题,比赛时看错题了。
#include <cstdio>
#include <iostream>
using namespace std;
int T;
long long n,m,z,l;
int main()
{
cin.sync_with_stdio(false);
cin>>T;
while(T--)
{
cin>>n>>m>>z>>l;
long long x = 0,ans = 0;
for(int i = 2;i <= n;i++)
{
x = (x*m + z) % l;
ans = ans ^ x;
}
cout<<ans*2<<endl;
}
}
MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to know the xor of all (Ai+Aj)(1≤i,j≤n)
The xor of an array B is defined as B1
xor B2...xor
Bn
[align=left]Input[/align]
Multiple test cases, the first line contains an integer T(no more than 20), indicating the number of cases.
Each test case contains four integers:n,m,z,l
A1=0,Ai=(Ai−1∗m+z)
mod
l
1≤m,z,l≤5∗105,n=5∗105
[align=left]Output[/align]
For every test.print the answer.
[align=left]Sample Input[/align]
2
3 5 5 7
6 8 8 9
[align=left]Sample Output[/align]
14
16
[align=left]Author[/align]
SXYZ
[align=left]Source[/align]
2015 Multi-University Training Contest 5
[align=left]Recommend[/align]
wange2014
分析:超级水题,比赛时看错题了。
#include <cstdio>
#include <iostream>
using namespace std;
int T;
long long n,m,z,l;
int main()
{
cin.sync_with_stdio(false);
cin>>T;
while(T--)
{
cin>>n>>m>>z>>l;
long long x = 0,ans = 0;
for(int i = 2;i <= n;i++)
{
x = (x*m + z) % l;
ans = ans ^ x;
}
cout<<ans*2<<endl;
}
}
相关文章推荐
- 单调栈/单调队列/RMQ
- VS2010使用c++、gSOAP调用WebService 图文教程
- Matrix67:漫话中文分词算法
- 对模拟登陆代码的理解
- 第二阶段个人总结5
- Oracle学习应用中的点点滴滴--自我记录长期更新
- 【DAY9】关于多线程的学习笔记
- property 中的strong 与weak
- 策略模式学习
- Problem3-总结报告
- 习题7-7 Egyptian Fractions (HARD version) 埃及分数 (IDA*)
- ACM 搜索 HDU 1728 搜索迷宫
- 蓝牙4.0BLE cc2540 cc2541 ios OAD教程(空中更新固件)[原创,多图]
- 第二次冲刺阶段站立会议(六)
- 第十三周学习进度
- Python2学习笔记(3)
- POJ1006 Biorhythms【中国剩余定理】
- iOS开发证书的整理
- Makefile详解--隐含规则
- c++ 指向类成员函数的函数指针