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 ...
随机推荐
- POJ 2014
#include <iostream> using namespace std; int main() { //freopen("acm.acm","r&qu ...
- Linux下搭建Android NDK , Linux 驱动开发环境
Eclispe Luna(4.4):http://www.eclipse.org/downloads/ CDT :http://www.eclipse.org/cdt/downloads.php AD ...
- To Use Ubuntuubunt
1.rename PC; modify the /etc/hostname. 2.Use root account; 1.set the password for root account: sudo ...
- C# 获取windows特殊路径
虽然是古老的问题,最近用到这个,查一下还不少东东呐 一.使用Environment.SpecialFolder 该方法最简单,直接使用即可,只是提供的特殊路径比较少. (1)使用方法:string p ...
- opencv face-detection 代码分析 (1)人脸识别后的数据
2014,3,16 老师的工作建议如下: 1. 与四民沟通下,把openCV这边的源代码和调用接口发给四民同时抄送给我. 2. 根据openCV的实时检测结果,实现对屏幕的调整(下周一前基本实 ...
- oracle连接数据
1.源代码 string connString = "User ID=scott;Password=yanhong;Data Source=(DESCRIPTION = (ADDRESS_L ...
- MongoDB (三) MongoDB 安装
MongoDB安装在Windows上 在 Windows上,首先要安装 MongoDB下载最新发布的MongoDB: http://www.mongodb.org/downloads 确保得到正确的版 ...
- 8天学通MongoDB——第一天 基础入门
原文地址:http://www.cnblogs.com/huangxincheng/archive/2012/02/18/2356595.html 关于mongodb的好处,优点之类的这里就不说了,唯 ...
- 华为OJ:字符串加解密
题目描述 1.对输入的字符串进行加解密,并输出. 2加密方法为: 当内容是英文字母时则用该英文字母的后一个字母替换,同时字母变换大小写,如字母a时则替换为B:字母Z时则替换为a: 当内容是数字时则把该 ...
- [iOS]如何删除工程里面用cocoapods导入的第三方库
如何在工程中卸载用cocoapods导入的第三方呢? 1. 打开工程所在文件夹 2. 打开Podfile文件 3. 删除不要的第三方导入命令 4. 然后在回到终端,然后进入到工程目录下,然后更新第三方 ...