MZL's xor

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/65536K (Java/Other)
Total Submission(s) : 1   Accepted Submission(s) : 1
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 ($A_i$+$A_j$)($1\leq i,j \leq n$)
The xor of an array B is defined as $B_1$ xor $B_2$...xor $B_n$
 
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$ $A_1=0$,$A_i=(A_{i-1}*m+z)$ $mod$ $l$ $1\leq m,z,l \leq 5*10^5$,$n=5*10^5$
 
Output
For every test.print the answer.
 
Sample Input
2 3 5 5 7 6 8 8 9
 
Sample Output
14 16
 题解:就是A数组可以得出,B数组是A[i]+A[j]组成的数组让求B1^B2^.......^Bn的值;
代码:
  1. #include<stdio.h>
  2. #include<string.h>
  3. const int MAXN=*1e5+;
  4. long long A[MAXN],B[MAXN];
  5. int main(){
  6. int T,n,m,z,l;
  7. scanf("%d",&T);
  8. while(T--){
  9. scanf("%d%d%d%d",&n,&m,&z,&l);
  10. A[]=;
  11. long long ans=;
  12. for(int i=;i<n;i++){
  13. A[i]=(A[i-]%l*m%l+z%l)%l;
  14. B[i]=A[i]+A[i];//因为相同的元素异或结果为0;所以A[i]+A[j] | A[j]+A[i]等于0;只剩相同元素之和的异或;
  15. ans^=B[i];
  16. }
  17. printf("%lld\n",ans);
  18. }
  19. return ;
  20. }

MZL's xor的更多相关文章

  1. hdu5344 MZL's xor(水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud MZL's xor Time Limit: 2000/1000 MS (Java/ ...

  2. hdu 5344 MZL's xor(数学之异或)

    Problem Description   MZL loves xor very much.Now he gets an array A.The length of A ≤i,j≤n) The xor ...

  3. hdu 5344 MZL's xor

    MZL's xor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  4. HDU 5344 MZL's xor (多校)[补7月28]

    MZL's xor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

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

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

  6. hdoj 5344 MZL's xor

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5344 #include<stdio.h> #include<cstring> ...

  7. HDU 5344(MZL&#39;s xor-(ai+aj)的异或和)

    MZL's xor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total ...

  8. 2015 多校联赛 ——HDU5344(水)

    Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to ...

  9. [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字

    Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...

随机推荐

  1. PagerAdapter instantiateItem()方法position错误解决方案

    异常信息:java.lang.IndexOutOfBoundsException: index=3 count=2 在instantiateItem各个条目View的时候.会有 container.a ...

  2. 记一次C++与lua连接

    今晚,花了两个多钟折腾lua和c++的互连,终于成功了,觉得有必要记录下来.说实话,搜索引擎真是有利有弊,利在你有地方搜答案,弊则在于你半天都找不到正确的答案甚至找到误导你的答案,今晚更加加深了我的体 ...

  3. selenium webdriver 学习笔记(一)

    selenium webdriver 第一个脚本: #coding = utf-8 from selenium import webdriver import time url = "htt ...

  4. Linux中的网络

    在windows 中表示一张网卡用本地连接1,本地连接2这种方式来表示:而在linux 中用的是etho,eth1 等等这样的东西来表示的.

  5. 15.java.lang.InstantiationException

    java.lang.InstantiationException 实例化异常 当试图通过Class的newInstance()方法创建某个类的实例,但程序无法通过该构造器来创建该对象时引发 Class ...

  6. Linux下面如何运行.sh文件

    Linux下面如何运行.sh文件   本文介绍Linux下面用命令如何运行.sh文件的方法,有两种方法: 一.直接./加上文件名.sh,如运行hello.sh为./hello.sh[hello.sh必 ...

  7. NOI2011 Day1

    NOI2011 Day1 兔农 题目描述:\(fib[1]=fib[2]=1, fib[i]=fib[i-2]+fib[i-1] (i\geq 3)\),若\(fib[i] \equiv 1(mod ...

  8. cors技术

    简称跨域资源共享: 若是配置nodejs: 需在公共路由添加三句话:代码如下: // 全局头设置 app.all('*', function(req, res, next) { res.set({ ' ...

  9. codechef Chef and The Right Triangles 题解

    Chef and The Right Triangles The Chef is given a list of N triangles. Each triangle is identfied by ...

  10. 达内TTS6.0课件oop_day05