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)(≤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 ), indicating the number of cases.
Each test case contains four integers:n,m,z,l
A1=,Ai=(Ai−∗m+z) mod l
≤m,z,l≤∗,n=∗

 
Output
For every test.print the answer.
 
Sample Input

 
Sample Output

 
Source
 

找到了规律就好办了,发现对称性,相同的数异或后等于0,所以最后剩下自身*2来异或,注意要用long long

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stdlib.h>
#include<map>
using namespace std;
#define ll long long
#define N 600000
ll n,m,z,l;
ll a[N];
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%I64d%I64d%I64d%I64d",&n,&m,&z,&l);
a[]=;
for(int i=;i<=n;i++){
a[i]=(a[i-]*m+z)%l;
}
ll ans=;
for(int i=;i<=n;i++){
ans=ans^(a[i]+a[i]);
}
printf("%I64d\n",ans);
}
return ;
}

hdu 5344 MZL's xor(数学之异或)的更多相关文章

  1. 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 ...

  2. hdu 5344 MZL's xor

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

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

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

  4. 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 ...

  5. hdoj 5344 MZL's xor

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

  6. 多校-HDU 5351 MZL's Border 数学规律

    f[1] = 'b', f[2] = 'a', f[i] = f[i - 1] + f[i - 2] 斐波那契数列的字符串,给你n和m,前m位中,最长的前缀等于后缀的长度是多少.1≤n≤1000, 1 ...

  7. hdu5344 MZL's xor(水题)

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

  8. MZL's xor

    MZL's xor Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/65536K (Java/Other) Total Sub ...

  9. HDU 5351 MZL's Border (规律,大数)

    [HDU 5351 MZL's Border]题意 定义字符串$f_1=b,f_2=a,f_i=f_{i-1}f_{i-2}$. 对$f_n$的长度为$m$的前缀$s$, 求最大的$k$满足$s[1] ...

随机推荐

  1. art.dialog

    关闭指定弹出窗: art.dialog({ id: 'hetong' }).close(); 关闭所有的iframe弹出窗,art.dia.close();

  2. MyBatis 通过包含的jdbcType类型和java中对应的数据类型

    MyBatis 通过包含的jdbcType类型 BIT         FLOAT      CHAR           TIMESTAMP       OTHER       UNDEFINED ...

  3. AngularJs学习笔记4——四大特性之双向数据绑定

    双向数据绑定 方向1:模型数据(model)绑定到视图(view) 实现方法:①.{{model变量名}}  ②.常用指令(ng-repeat) 方向2:将视图(view)中用户输入的数据绑定到模型数 ...

  4. traceroute原理

    traceroute原理 ICMP ICMP全称为Internet Control Message Protocol,即,网络控制报文协议. 当一个IP数据报发送失败时,最后一个路由器会向发送发传递一 ...

  5. python - socket模块1

    1.使用生活中的接打电话,解释socket通信流程  2.根据上图,写出socket通信的伪代码 2.1.server端伪代码 #买手机   #买手机卡 #开机 #等待电话 #收消息 #发消息 #挂电 ...

  6. SuperSocket学习笔记(一)

    这是根据我自己学习的经历整理出来的,如有不对之处,还请多多指教! SuperSocket源码下载 SuperSocket文档 安装并启动Telnet 学习方法: QuickStrart + 文档 参考 ...

  7. mysql的锁--行锁,表锁,乐观锁,悲观锁

    一 引言--为什么mysql提供了锁 最近看到了mysql有行锁和表锁两个概念,越想越疑惑.为什么mysql要提供锁机制,而且这种机制不是一个摆设,还有很多人在用.在现代数据库里几乎有事务机制,aci ...

  8. js的水仙花数的输出

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. Find The Multiple

    算法:深搜(水题): Given a positive integer n, write a program to find out a nonzero multiple m of n whose d ...

  10. CODEVS 3139 栈练习3

    3139 栈练习3  时间限制: 2 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description 比起第一题,本题加了另外一个操作,访问栈顶元素(编号3,保 ...