HDU 5344 MZL's xor (水题)
题意:给一个序列A,设序列B的中的元素有(Ai+Aj)(1≤i,j≤n),那么求B中所有元素的异或之和。而序列A是这样来的:A1=0,Ai=(Ai−1∗m+z) mod l。
思路:相同的元素异或结果为0,所以可以去掉,也就是剩下A中的元素ai+ai那些而已。 小心乘法会溢出
#include <bits/stdc++.h>
#define INF 0x7f7f7f7f
#define pii pair<int,int>
#define LL long long
using namespace std;
const int N=*1e5+; int vect[N]; int main()
{
//freopen("input.txt", "r", stdin);
int t, n, m, z, l;
cin>>t;
while(t--)
{
scanf("%d %d %d %d",&n, &m, &z, &l);
memset(vect, , sizeof(vect));
LL pre=, big=;
for(int i=; i<n; i++)
{
vect[ (pre*m+z)%l ]++;
pre=(pre*m+z)%l ;
big=max(big, pre);
}
int ans=;
for(int i=; i<N; i++)
{
if( vect[i]%==)
{
ans^=(i+i);
}
}
printf("%d\n",ans); }
return ;
}
AC代码
HDU 5344 MZL's xor (水题)的更多相关文章
- hdu5344 MZL's xor(水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud MZL's xor Time Limit: 2000/1000 MS (Java/ ...
- 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
MZL's xor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- 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 5578 Friendship of Frog 水题
Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5590 ZYB's Biology 水题
ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- HDU 5538 L - House Building 水题
L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- hdu 1005:Number Sequence(水题)
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- hdu 1018:Big Number(水题)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
随机推荐
- String Reduction
问题出自这里 问题描述: Given a string consisting of a,b and c's, we can perform the following operation: Take ...
- Win7系统配置IIS7服务
1.开启IIS7服务 打开控制面板,选择并进入“程序”,双击“打开或关闭Windows服务”,在弹出的窗口中选择“Internet信息服务”下面所有地选项,点击确定后,开始更新服务. 2.安装web文 ...
- shape和selector的结合使用
shape和selector是Android UI设计中经常用到的,比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到shape和selector.可以这样说,shape和 ...
- Shell脚本基础I
1.Linux shell类型 /bin/sh--已经被/bin/bash所取代 /bin/bash--就是Linux预设的shell /bin/ksh--由AT&T Bell lab发展出来 ...
- iOS开发--CoreGraphics简单绘图
一.导入coreGraphics.framework 二.绘制图形 1.绘制矩形 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 // 绘制矩形 - (v ...
- Fatal error: cannot allocate memory for the buffer pool
mysql有时候会被系统kill掉,原因是内存不够了,一般都是Ubuntu出现的,因为Ubuntu吃内存,你们又给的不多.. 咋解决呢? 重启服务器是可以的,起码暂时可以了, 可以考虑加内存,或者增加 ...
- 275. H-Index II
题目: Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optim ...
- CentOS中通过stat查看文件的元数据
CentOS中可以通过stat查看文件的元数据 [baby@xiaoxiao abc]$ stat honey File: `honey' Size: 25 Blocks: 8 ...
- SpringBoot配置属性之Server
SpringBoot配置属性系列 SpringBoot配置属性之MVC SpringBoot配置属性之Server SpringBoot配置属性之DataSource SpringBoot配置属性之N ...
- spring各个包之间的依赖关系
从图中可以看到: 1.spring core,spring beans被其他较多包依赖,spring aop,spring context,spring expression分别被两个包依赖,而spr ...