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. HDU——T 1498 50 years, 50 colors

    http://acm.hdu.edu.cn/showproblem.php?pid=1498 Time Limit: 2000/1000 MS (Java/Others)    Memory Limi ...

  2. codevs——T2488 绿豆蛙的归宿

    http://codevs.cn/problem/2488/  时间限制: 1 s  空间限制: 64000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Descri ...

  3. HDU 4328 Contest 3

    悬线法可解,稍有点烦琐. #include <iostream> #include <cstdio> #include <cstring> #include < ...

  4. 译:MySQL性能优化的21条最佳经验

    今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据 ...

  5. Android开发工具---SQLiteManager插件

    Android开发工具---SQLiteManager插件 效果图例如以下: 平时在开发过程中查看数据库都要把数据库文件导出来,然后再用其它工具打开,SQLiteManager插件则给予我们一些便利. ...

  6. 小贝_mysql三种子查询

    mysql三种子查询 简要: 一.三种子查询 二.三种子查询理解模型 一.mysql 三种子查询 where子查询.from子查询.exists子查询 二.理解模型: 2.1.一个好的模型,便于我们去 ...

  7. 从头认识java-15.3 使用HashSet须要注意的地方

    这一章节我们来讨论一下使用Set的各种实现须要注意的地方. Set接口的经常使用实现类有:HashSet.TreeSet,LinkedHashSet 1.HashSet 大家对于HashSet的印象都 ...

  8. Android笔记三十三.BroadcastReceiver使用

        广播是一种广泛运用在应用程序之间传输信息的机制,而BroadcastReceiver是对发送出来的广播进行过滤接收并响应的一类组件. BroadcastReceiver本质上是一种全局监听器. ...

  9. bzoj2190: [SDOI2008]仪仗队(欧拉)

    2190: [SDOI2008]仪仗队 题目:传送门 题解: 跟着企鹅大佬做题! 自己瞎搞搞就OK,不难发现,如果以C作为原点建立平面直角坐标系,那么在这个坐标系中,坐标为(x,y)且GCD(x,y) ...

  10. m_Orchestrate learning system---四、多看参考文档很多事情很轻松就解决了

    m_Orchestrate learning system---四.多看参考文档很多事情很轻松就解决了 一.总结 一句话总结:多看参考文档啊 1.面包屑导航如何实现? 1 <ol class=& ...