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
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
typedef long long ll;
const int maxn = 0x3f3f3f3f;
using namespace std;
ll a[500010]; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,m,k,l;
memset(a,0,sizeof(a));
scanf("%d%d%d%d",&n,&m,&k,&l);
a[1] = 0;
for(int i = 2;i <= n;i++)
a[i] = (a[i-1]*m+k)%l;
for(int i = 2;i <= n;i++)
a[i]^=a[i-1];
printf("%I64d\n",a[n]*2);
}
return 0;
}

  

2015 多校联赛 ——HDU5344(水)的更多相关文章

  1. 2015 多校联赛 ——HDU5400(水)

    Sample Input 5 2 -2 0 2 0 -2 0 5 2 3 2 3 3 3 3   Sample Output 12 5 求最多多少序列满足,前半部分满足d(j+1) = d(j)+d1 ...

  2. 2015 多校联赛 ——HDU5349(水)

    Problem Description A simple problem Problem Description You have a multiple set,and now there are t ...

  3. 2015 多校联赛 ——HDU5334(构造)

    Virtual Participation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  4. 2015 多校联赛 ——HDU5302(构造)

    Connect the Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  5. 2015 多校联赛 ——HDU5294(最短路,最小切割)

    Tricks Device Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  6. 2015 多校联赛 ——HDU5325(DFS)

    Crazy Bobo Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Tota ...

  7. 2015 多校联赛 ——HDU5316(线段树)

    Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...

  8. 2015 多校联赛 ——HDU5323(搜索)

    Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  9. 2015 多校联赛 ——HDU5319(模拟)

    Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Su ...

随机推荐

  1. TCP和UDP的最完整的区别

    TCP UDP TCP与UDP基本区别   1.基于连接与无连接   2.TCP要求系统资源较多,UDP较少:    3.UDP程序结构较简单    4.流模式(TCP)与数据报模式(UDP);    ...

  2. RxSwift:ReactiveX for Swift 翻译

    RxSwift:ReactiveX for Swift 翻译 字数1787 阅读269 评论3 喜欢3 图片发自简书App RxSwift | |-LICENSE.md |-README.md |-R ...

  3. UVA 10622 Perfect P-th Powers

    https://vjudge.net/problem/UVA-10622 将n分解质因数,指数的gcd就是答案 如果n是负数,将答案除2至奇数 原理:(a*b)^p=a^p*b^p #include& ...

  4. ebtables和iptables与linux bridge的交互

    本文为翻译文,不一定是逐字逐句的翻译,而且中间会加上自己的一点见解,如有理解错误的地方,还请大家指出,我定虚心学习.原文见链接 其中斜体字是自己的理解,建议和ebtables手册和iptables手册 ...

  5. 新概念英语(1-59)Is that all

    Does the lady buy any chalk? A:I want some envelopes, please. B:Do you want the large size or the sm ...

  6. SpringBoot 概念和起步

    一.概念和由来 1.什么是 Spring Boot Spring Boot 的设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用特定方式来进行配置,从而使开发人员不再需要定义样板化 ...

  7. windows server 2016远程桌面进去,英文系统修改语言

    由于我这边已经是改好了,以下截图来自中文版. 这边选了中文,然后点options. 选择:使该语言成为主要语言,保存. 会提示需要退出登录. 过一会重新登录,ok.

  8. mysql解压缩版本的安装、初始化等

    https://dev.mysql.com/doc/refman/5.7/en/windows-install-archive.html 启动或者暂停mysql服务: https://dev.mysq ...

  9. Docker Win 10 安装

    最近了解了一下Docker,不看不知道,一了解就完全被它给吸引住了.以往要装个环境,除了要准备一个Linux系统,然后在安装各种版本的类库,再安装我们需要各种应用服务(如Redis,Ngix,Mong ...

  10. Java:Java 中会存在内存泄漏吗

    理论上Java因为有垃圾回收机制(GC)不会存在内存泄露问题(这也是Java被广泛使用于服务器端编程的一个重要原因):然而在实际开发中,可能会存在无用但可达的对象,这些对象不能被GC回收,因此也会导致 ...