MZL's xor

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 800    Accepted Submission(s): 518

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
 
Author
SXYZ
 
Source
 
Recommend
wange2014   |   We have carefully selected several similar problems for you:  5416 5415 5414 5413 5412 
 

(Ai+Aj)^(Aj+Ai)=0 (i≠j)

然后注意开long long 否则 ai*m时会爆

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define MAXN (5000000+10)
typedef long long ll;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return (a-b+llabs(a-b)/F*F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
ll a[MAXN];
ll n,m,z,l;
int main()
{
// freopen("B.in","r",stdin);
int T;cin>>T;
while(T--)
{
cin>>n>>m>>z>>l;
a[1]=0;
Fork(i,2,n) a[i]=(a[i-1]*m+z)%l;
ll s=0;
For(i,n) s=s^(2*a[i]);
cout<<s<<endl;
} return 0;
}

HDU 5344(MZL&#39;s xor-(ai+aj)的异或和)的更多相关文章

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

  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 (多校)[补7月28]

    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 (水题)

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

  5. HDU 5347(MZL&#39;s chemistry-打表)

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

  6. hdu 5348 MZL&#39;s endless loop

    给一个无向图(事实上是有向的.可是没有指定边的方向),你须要指定边的方向,使得每一个点入度和出度相差不超过1. 事实上就是找很多条路径.合起来能走完这个图..先统计各个顶点的度.度为奇数必是起点或终点 ...

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

  8. CodeForces 702B Powers of Two【二分/lower_bound找多少个数/给出一个数组 求出ai + aj等于2的幂的数对个数】

    B. Powers of Two   You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i,  ...

  9. 已知一个序列A1.A2….An,给你一个整数K,找到满足所有Ai+Aj>=k的数对(i,j)的个数

    #include<bits/stdc++.h> using namespace std; #define ll long long #define maxn 100010 /* 已知一个序 ...

随机推荐

  1. 关于C++的一些函数的使用方法

    关于C++的一些函数的使用方法: http://www.shouce.ren/api/c/index.html

  2. Spring Cloud Feign 出现ClassNotFoundException: feign.Feign$Builder错误

    Spring Cloud Feign 出现ClassNotFoundException: feign.Feign$Builder错误 后来发现是POM文件写错了,修改为正确的pom,就可以了: POM ...

  3. oracle刚開始学习的人经常使用操作100问

    oracle刚開始学习的人经常使用操作100问 1. Oracle安装完毕后的初始口令?   internal/oracle sys/change_on_install system/manager ...

  4. Scrapy研究探索(六)——自己主动爬取网页之II(CrawlSpider)

    原创,转载注明:http://blog.csdn.net/u012150179/article/details/34913315 一.目的. 在教程(二)(http://blog.csdn.net/u ...

  5. Cocos2d-x-lua学习点滴

    Lua下的方法.自己项目经验,个人见解,不能确保正确. Sprite: local Light = CCSprite:create("light.png")             ...

  6. ActionBarActivity设置全屏无标题

    新建的Activity继承自ActionBarActivity,设置全屏无标题本来非常easy的事,可是没想到app居然无缘无故的挂,要么就是白屏一片,要么就是黑屏.坑了我一个多小时.!! 原因是Ac ...

  7. html单行、多行文本溢出隐藏

    欢迎加入前端交流群来py:749539640 单行: div{/* 单行溢出隐藏 */ width: 150px; white-space: nowrap; overflow: hidden; tex ...

  8. autocomplete="off" 不起作用解决方案

    autocomplete属性是表单字段中的HTML5新属性,该属性有两种状态值,分别为"on" 和 "off",该属性可省略:省略属性值后默认值为"o ...

  9. 51nod 1307 绳子与重物 (标记父节点更新即可)

    1307 绳子与重物 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 有N条绳子编号 0 至 N - 1,每条绳子后面栓了一个重物重量为Wi,绳子的最大负重为Ci. ...

  10. Volatile variables

    Volatile variables apply another type of memory constraint to individual variables. The compiler oft ...