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的值;
代码:
 #include<stdio.h>
#include<string.h>
const int MAXN=*1e5+;
long long A[MAXN],B[MAXN];
int main(){
int T,n,m,z,l;
scanf("%d",&T);
while(T--){
scanf("%d%d%d%d",&n,&m,&z,&l);
A[]=;
long long ans=;
for(int i=;i<n;i++){
A[i]=(A[i-]%l*m%l+z%l)%l;
B[i]=A[i]+A[i];//因为相同的元素异或结果为0;所以A[i]+A[j] | A[j]+A[i]等于0;只剩相同元素之和的异或;
ans^=B[i];
}
printf("%lld\n",ans);
}
return ;
}

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. 第6章 堆排序,d叉堆,优先队列

    #include<stdio.h> #include<stdlib.h> #include<string.h> #define leftChild(i) (2*(i ...

  2. 【Chromium中文文档】插件架构

    插件架构 转载请注明出处:https://ahangchen.gitbooks.io/chromium_doc_zh/content/zh//General_Architecture/Plugin_A ...

  3. 一些User-Agent

    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)", "Mozilla/4.0 (compatible; MSIE ...

  4. git创建标签

    创建标签 在Git中打标签非常简单,首先,切换到需要打标签的分支上: $ git branch * dev master $ git checkout master Switched to branc ...

  5. 在 Windows Azure 虚拟机中如何备份和还原 Windows 系统磁盘

    备份和还原对于操作真实的系统来说至关重要.对于 Windows Azure 虚拟机环境中的 Windows Server,可以根据自身的需求选择多种不同的工具或将这些工具结合使用来实现备份.下面将对这 ...

  6. [置顶] Oracle GoldenGate 常见问题:长事务处理

    长事务的影响 OGG是基于事务级的实时复制工具,也就是说OGG只复制已提交的事务,在遇到事务的commit或rollback之前,它会将每个事务的操作存储在称为cache的托管虚拟内存池中.内存再大也 ...

  7. 【HTML5】DOMContentLoaded事件

    这个事件是从HTML中的onLoad的延伸而来的,当一个页面完成加载时,初始化脚本的方法是使用load事件,但这个类函数的缺点是仅在所有资源都完全加载后才被触发,这有时会导致比较严重的延迟,开发人员随 ...

  8. oracle添加用户及权限

    CREATE USER qdcenter 用户名 IDENTIFIED BY qdcenter   密码 DEFAULT TABLESPACE data1  默认表空间 TEMPORARY TABLE ...

  9. SQL练习之求解填字游戏

    SELECT * FROM dbo.spt_values

  10. MATLAB一句总结

    MATLAB使用过程中的一些小总结: 1.sqrt函数的输入参数应为double类型: 2.im2bw把图像转换为二值图像: 3.double类型的图片必须转换为uint8类型后才能用imshow显示 ...