转载请注明出处: 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的异或值

  1. /**
  2. * code generated by JHelper
  3. * More info: https://github.com/AlexeyDmitriev/JHelper
  4. * @author xyiyy @https://github.com/xyiyy
  5. */
  6.  
  7. #include <iostream>
  8. #include <fstream>
  9.  
  10. //#####################
  11. //Author:fraud
  12. //Blog: http://www.cnblogs.com/fraud/
  13. //#####################
  14. //#pragma comment(linker, "/STACK:102400000,102400000")
  15. #include <iostream>
  16. #include <sstream>
  17. #include <ios>
  18. #include <iomanip>
  19. #include <functional>
  20. #include <algorithm>
  21. #include <vector>
  22. #include <string>
  23. #include <list>
  24. #include <queue>
  25. #include <deque>
  26. #include <stack>
  27. #include <set>
  28. #include <map>
  29. #include <cstdio>
  30. #include <cstdlib>
  31. #include <cmath>
  32. #include <cstring>
  33. #include <climits>
  34. #include <cctype>
  35.  
  36. using namespace std;
  37. #define rep(X, N) for(int X=0;X<N;X++)
  38. typedef long long ll;
  39.  
  40. class hdu5344 {
  41. public:
  42. void solve(std::istream &in, std::ostream &out) {
  43. int t;
  44. in >> t;
  45. while (t--) {
  46. ll m, z, l, n;
  47. in >> n >> m >> z >> l;
  48. ll x = ;
  49. ll ans = ;
  50. rep(i, n) {
  51. ans ^= (x + x);
  52. x = (x * m + z) % l;
  53. }
  54. out << ans << endl;
  55. }
  56. }
  57. };
  58.  
  59. int main() {
  60. std::ios::sync_with_stdio(false);
  61. std::cin.tie();
  62. hdu5344 solver;
  63. std::istream &in(std::cin);
  64. std::ostream &out(std::cout);
  65. solver.solve(in, out);
  66. return ;
  67. }

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 688 - Mobile Phone Coverage

    经典问题,矩形面积并. 解法:一.矩形分割,每个矩形的两个横坐标和两个纵坐标排序,这样得到2n*2n个区间,对这些区间依次判断是否包含在n个矩形中间即可.      二.扫描线.具体还没实现过. 详见 ...

  2. jquery的鼠标移入移出事件hover、mouseenter、mouseleave、mouseover、mouseout

    hover:鼠标进入元素的子元素时不会触发‘鼠标移开’的事件: mouseenter.mouseleave:效果与hover相同: mouseover: 鼠标进入元素和进入它的子元素时都会触发‘mou ...

  3. 作业:汽车查询--弹窗显示详情,批量删除 php做法(0521)

    作业:显示以下界面: 作业要求: 1.查看详细信息,以弹窗的形式显示,使用ajax2.批量删除 一.主页面: <!DOCTYPE html PUBLIC "-//W3C//DTD XH ...

  4. CI框架中遇见的一些错误和解决方法 笔记

    ps:根据经验不断修改和更新,欢迎指出错误~ 1. An uncaught Exception was encountered Type: Exception Message: Session: Co ...

  5. pyqt5:标签显示文本框内容

    文本框(lineEdit)输入文本,标签(label)就会显示文本框的内容. 原理如下: 输入文本时,lineEdit控件发射信号textChanged(),label收到后触发setText()槽. ...

  6. Activiti 使用自己的身份认证服务

    Activiti 中内置了用户和组管理的服务,由identityService 提供调用接口,默认在spring配置中如下: <bean id="identityService&quo ...

  7. $rootScope

    参考地址 https://docs.angularjs.org/api/ng/type/$rootScope.Scope angular 的scope一般上都是有继承关系的,也就是说可以通过原型访问到 ...

  8. 如何看懂XDEBUG+WEBGRIND?(转)

    看到一个很有用的东东,收藏.. http://blog.csdn.net/yukon12345/article/details/11408617 ~~~~~~~~~~ 使用:              ...

  9. haskell学习笔记_函数

    一开始学习函数式编程语言就被告知函数式编程语言是一种“定义式”的语言,而不是一种命令式的语言,在学习haskell的函数语法时,此感觉更加强烈,haskell的函数定义倾向于一种类似C++里面的swi ...

  10. 防止DC电源反接的方法——SS14的用法

    出处:http://blog.ednchina.com/tengjingshu 电源是PCB板的重要部分,每个芯片都需要电源供给.芯片其实是挺脆弱的,只要正负接反得话,大多数就会挂掉,相信很多人都有惨 ...