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. 【Oracle学习笔记】

    内容主要包括: (1)三种循环及其简化 (2)游标的使用 (3)异常处理 (4)存储过程 (5)存储函数 (6)触发器 (7)其它pl/sql操作 ---------------loop循环定义变量- ...

  2. MyEclipse中安装Testng插件

    下载testng.eclipse插件 Testng相应jar包,这里使用的是5.12的版本号 直接找到myeclipse的安装文件夹,将org.testng.eclipse_5.12.0.6.jar ...

  3. Android上方便地开发的C程序

    假设你基于没有一个专门的开发板练手.那你的Android手机也能够开发大多数C应用程序.安装好后编译C的编译器. 本文仅仅写一个Hello World的执行过程. 长处是:不须要eclipse,不须要 ...

  4. ThinkPHP新建控制器

    ThinkPHP新建控制器 一.效果图 二.步骤 1.新建控制器文件 2.编写控制器文件 3.访问控制器 三.注意事项

  5. zzulioj--1712--Monty Hall problem(蒙提霍尔问题)

     1721: Monty Hall problem Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 186  Solved: 71 SubmitSt ...

  6. 132.try throw catch介绍

    #include <iostream> using namespace std; //try尝试执行,抛出throw,throw之后语句不再执行 //catch处理throw的异常 voi ...

  7. BZOJ 4636 (动态开节点)线段树

    思路: 偷懒 懒得离散化 搞了个动态开节点的线段树 (其实是一样的--..) 注意会有a=b的情况 要判掉 //By SiriusRen #include <cstdio> #includ ...

  8. 终于意识到BIM确实火了

    碰巧遇到一个BIM会议.一大帮国内的老师桠桠叉叉坐了一大屋.听了半天感觉都是在吹BIM如何火.第一次听到这个概念感觉这个能火吗. 昨天雄安新区用BIM建设的新闻出来后,一下子惊了.看来BIM进入计算机 ...

  9. 51nod 1632 B君的连通

    题目: 这题看起来难,其实这么多概率啥的都是唬人的.甚至连快速幂都不用就可以解. 解法:    n个节点,n-1条边,期望会有一半的边被炸毁(因为总体概率就是50%). 即(n-1)/2条边被炸毁,这 ...

  10. 监控慢SQL

    SELECT G.TARGET || ' ' || S.MACHINE || ' ' || ceil((G.LAST_UPDATE_TIME - G.START_TIME)*86400)   FROM ...