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 ...
随机推荐
- iOSpush过后返回多级界面
有导航控制器push过后pop可以反回上一个界面,然而我们需要返回多级界面有下面两种方法 调用API - (NSArray *)popToViewController:(UIViewControlle ...
- POJ 1607
#include<iostream> #include<iomanip> using namespace std; int main() { //freopen("a ...
- linux下ssh/scp无密钥登陆方法
一.双方机器都是root用户登陆方法 A为本地主机(即用于控制其他主机的机器) ;B为远程主机(即被控制的机器Server), 假如ip为192.168.60.110;A和B的系统都是Linux 在A ...
- HtmlAgilityPack 之 HtmlNode类
HtmlAgilityPack中的HtmlNode类与XmlNode类差不多,提供的功能也大同小异.下面来看看该类提供功能. 一.静态属性 public static Dictionary<st ...
- ngrok本地反向代理
ngrok本地反向代理 ngrok本地反向代理 使用ngrok可以把内网服务映射到外网 国内ngrok服务配置如下 在ngrok.exe所在的目录下添加ngrok.cfg文件 ngrok.cfg文件内 ...
- lintcode: 最小调整代价
题目 最小调整代价 给一个整数数组,调整每个数的大小,使得相邻的两个数的差小于一个给定的整数target,调整每个数的代价为调整前后的差的绝对值,求调整代价之和最小是多少. 样例 对于数组,最小的调整 ...
- Hibernate的配置文件解析
配置mybatis.xml或hibernate.cfg.xml报错: <property name="connection.url">jdbc:mysql://loca ...
- openstack配置注意事项(主要是网络相关)
vlan协议应该配置为802.1q,另一个容易混淆的为ISL,配置命令为 switchport trunk encapsulation dot1q /islswitchport mode trunk ...
- USACO Section 4.2: The Perfect Stall
这题关键就在将题转换成最大流模板题.首先有一个原始点,N个cow个点, M个barn点和一个终点,原始点到cow点和barn点到终点的流都为1,而cow对应的barn就是cow点到对应barn点的流, ...
- [原]poj-3009-Curling 2.0-dfs
题目太长就不贴了,题意: 上下左右四联通块,2表示起点,3表示终点,1为block,0为空地,每动一次冰壶,冰壶就会向推动的方向一直移动,直到碰到block或出界,如果碰到block就在block前停 ...