转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud

MZL's xor

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 488    Accepted Submission(s): 342

Problem Description
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
 
Input
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
 
Output
For every test.print the answer.
 
Sample Input
2
3 5 5 7
6 8 8 9
 
Sample Output
14 16

两个相同的数异或之后等于0,最终只剩下Ai+Ai的异或值

 /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author xyiyy @https://github.com/xyiyy
*/ #include <iostream>
#include <fstream> //#####################
//Author:fraud
//Blog: http://www.cnblogs.com/fraud/
//#####################
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <sstream>
#include <ios>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype> using namespace std;
#define rep(X, N) for(int X=0;X<N;X++)
typedef long long ll; class hdu5344 {
public:
void solve(std::istream &in, std::ostream &out) {
int t;
in >> t;
while (t--) {
ll m, z, l, n;
in >> n >> m >> z >> l;
ll x = ;
ll ans = ;
rep(i, n) {
ans ^= (x + x);
x = (x * m + z) % l;
}
out << ans << endl;
}
}
}; int main() {
std::ios::sync_with_stdio(false);
std::cin.tie();
hdu5344 solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return ;
}

hdu5344 MZL's xor(水题)的更多相关文章

  1. HDU 5344 MZL's xor (水题)

    题意:给一个序列A,设序列B的中的元素有(Ai+Aj)(1≤i,j≤n),那么求B中所有元素的异或之和.而序列A是这样来的:A1=0,Ai=(Ai−1∗m+z) mod l. 思路:相同的元素异或结果 ...

  2. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  3. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  4. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  5. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  6. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  7. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  8. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  9. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

随机推荐

  1. uva 10922 - 2 the 9s

    題目意思:讀取一數字,此數字最大有1000位.計算該數字是否為九的倍數?如是,再計算其階層數. ※判斷是否為九的倍數:所有位數相加 ÷ 9=0,即為九的倍數. ※計算階層數:所有位數相加後得出的第一個 ...

  2. Github提交代码及分支管理

    #提交代码cd <Cat>git initgit add .git statusgit commit -m "注释"git remote add origin < ...

  3. secureCRT命令大全

    常用命令:一.ls 只列出文件名-a:列出所有文件,包含隐藏文件.(ll -a)-l:列表形式,包含文件的绝大部分属性.(ll)-r:递归显示.(ll -r)--help:此命令的帮助.(ll --h ...

  4. Lintcode--011(打劫房屋2)

    在上次打劫完一条街道之后,窃贼又发现了一个新的可以打劫的地方,但这次所有的房子围成了一个圈,这就意味着第一间房子和最后一间房子是挨着的.每个房子都存放着特定金额的钱.你面临的唯一约束条件是:相邻的房子 ...

  5. JavsScript的基本特点

    1.简单性Javascript是一种脚本语言,它采用小程序段的方式实现编程它同样也是一种解释性语言.2.动态性Javascript是动态的,它可以直接对用户或者客户输入做出相应,无须经过Web服务程序 ...

  6. Katana 还是Owin ? 本地自承载

    使用Owin 将Web项目脱离 IIS确实很特别..... 由此 ,可以衍生出,一个新的通信渠道,本地Server的自承载. 1 Node.js 2 Python 3 Ruby 4 Owin (C#- ...

  7. VS2010 Command Prompt Error:Cannot determine the location of the VS Common Tools folder

    就在VS2010 Command Prompt 用vcvarsall.bat x64重新设置环境变量的时候,出现了标题中的错误.原因就在参考链接中 References: http://stackov ...

  8. Ext中窗体第二次点击报错或者其内控件不显示的问题,弄了2天才解决,记录下

    registerPanel.js: registerPanel = new Ext.form.FormPanel({ id:'registerPanel', layout:'form', autoHe ...

  9. c指针点滴4-指针的值

    #include <stdio.h> #include <stdlib.h> void main() { ; int *p = &num; //double *p1 = ...

  10. WPF 控件之ComboBox绑定[2]

    最近感觉新的方法Binding comboBox用起来很好用. 记录一下: <ComboBox Grid.Row=" x:Name="cboFamilyName" ...