hdu 5344 MZL's xor
MZL's xor
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 911 Accepted Submission(s): 589
The xor of an array B is defined as B1 xor B2...xor Bn
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
3 5 5 7
6 8 8 9
16
i!=j时(Ai+Aj)xor(Ai+Aj)=0,剩下(A1+A1)xor(A2+A2)xor...xor(An+An),而Ai=(Ai−1∗m+z) mod l是产生随机数的函数,在一定长度下会出现循环,循环部分又可以约掉
#include<cstdio>
#include<cstring>
bool b[];
int a[];
int main()
{
long long z, m, l;
int n, T;
scanf("%d", &T);
while (T--)
{
scanf("%d%lld%lld%lld", &n, &m, &z, &l);
int j, f, L, i;
memset(b, , sizeof(b));
L = ;
b[] = true;
a[] = ;
for (j = ;; j++)
{
L = (m*L + z) % l;//随机数产生函数,会有循环出现
if (b[L] == true) break;
b[L] = true;
a[j] = L;
}
int sum = ;
for (f = ; f < j; f++)
{
if (a[f] == L) break;
sum = sum ^ (a[f] << );
}
int cycle = j - f;
int div = (n - f) / cycle;
int mod = (n - f) % cycle;
if (div & )
{
for (i = f + mod; i < j; i++)
sum = sum ^ (a[i] << );
}
else
{
for (i = f; i < f + mod; i++)
sum = sum ^ (a[i] << );
}
printf("%d\n", sum);
}
}
hdu 5344 MZL's xor的更多相关文章
- 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 ...
- 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 ...
- HDU 5344 MZL's xor (水题)
题意:给一个序列A,设序列B的中的元素有(Ai+Aj)(1≤i,j≤n),那么求B中所有元素的异或之和.而序列A是这样来的:A1=0,Ai=(Ai−1∗m+z) mod l. 思路:相同的元素异或结果 ...
- HDU 5344(MZL's xor-(ai+aj)的异或和)
MZL's xor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...
- hdoj 5344 MZL's xor
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5344 #include<stdio.h> #include<cstring> ...
- 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] ...
- hdu5344 MZL's xor(水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud MZL's xor Time Limit: 2000/1000 MS (Java/ ...
- MZL's xor
MZL's xor Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/65536K (Java/Other) Total Sub ...
- Hdu 5352 MZL's City (多重匹配)
题目链接: Hdu 5352 MZL's City 题目描述: 有n各节点,m个操作.刚开始的时候节点都是相互独立的,一共有三种操作: 1:把所有和x在一个连通块内的未重建过的点全部重建. 2:建立一 ...
随机推荐
- AnimatorController动画遮罩
游戏中,我们的人物在某些时候,可能在一个时间点在做两件事,这样就需要同时播放两个动画,但我们肯定不能简单将其叠加,比如移动着开枪.攻击.挥手等等,那么在Unity中我们应该怎样实现这样的功能呢?且听我 ...
- 面试中有关C++的若干问题
面试中有关C++的若干问题 By 晴天, 2014.5.16晚 什么是多态?简要说一下C++中的多态的概念. (1)定义:多态是指相同对象收到不同消息或者不同对象收到相同消息产生不同的行为. (2)C ...
- Gentoo:Xorg:Failed to load module "……" 问题
错误描述: 安装完xorg-server后,startx启动桌面环境,出现缺少模块错误. Xorg:Failed to load module "--" 查看log: cat /v ...
- insertMany
结果:
- Chapter 14_3 非全局的环境
关于“环境”的一大问题在于它是全局的,任何对它的修改都会影响程序的所有部分. 例如:若安装一个元表用于控制全局变量的访问,那么整个程序都必须遵循这个规范. 当使用某个库时,没有先声明就使用了全局变量, ...
- UIAlertAction 弹出对话框9.0后有点变化
ios 9.0后再用以前的UIAlertAction 已经不行了 被弃用了 改用这种方法了 UIAlertController *alertController = [UIAlertControlle ...
- 解决curl中errno为51和60的错误
今天使用curl调用https接口的时候,发现接收不了数据 然后打印出curl_errno和curl_error发现是60错误,而生产环境是51错误 查了相关资料 加上两个参数就可以了 curl_se ...
- CentOS 7 多网卡绑定
根据官方文档Red_Hat_Enterprise_Linux-7-Networking_Guide-en-US用nmcli做起来还是相当容易的.下面把俺的步骤贴下. 1.查看目前网卡的名称和状态.#n ...
- SqlSever 查询基本
查询语句: SQL sever 查询语句: 1.查询所有字段: select * from UserInfo 2.条件筛选 (如查询UserInfo中的UserName) select UserNam ...
- hadoop pig入门总结
在这里贴一个pig源码的分析,做pig很长时间没做笔记,不包含任何细节,以后有机会再说吧 http://blackproof.iteye.com/blog/1769219 hadoop pig入门总结 ...