hdu-5683 zxa and xor (位运算)
题目链接:
zxa and xor
Time Limit: 16000/8000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
zxa thought only doing this was too boring, hence a function funct(x,y) defined by him, in which ax would be changed into y irrevocably and then compute ⊗1≤i<j≤n(ai+aj) as return value.
zxa is interested to know, assuming that he called such function m times for this sequence, then what is the return value for each calling, can you help him?
tips:⊗1≤i<j≤n(ai+aj) means that (a1+a2)⊗(a1+a3)⊗⋯⊗(a1+an)⊗(a2+a3)⊗(a2+a4)⊗⋯⊗(a2+an)⊗⋯⊗(an−1+an).
For each test case:
The first line contains two positive integers n and m.
The second line contains n non-negative integers, represent a1,a2,⋯,an.
The next m lines, the i-th line contains two non-negative integers x and y, represent the i-th called function is funct(x,y).
There is a blank between each integer with no other extra space in one line.
1≤T≤1000,2≤n≤2⋅10^4,1≤m≤2⋅10^4,0≤ai,y≤10^9,1≤x≤n,1≤∑n,∑m≤10^5
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
const LL mod=1e9+;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int N=2e4+;
int n,m;
int a[N],ans;
int get_ans()
{
ans=;
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n;j++)
{
int sum=a[i]+a[j];
ans^=sum;
}
}
}
int fun(int fx,int fy)
{
for(int i=;i<=n;i++)
{
if(i!=fx) ans^=(a[fx]+a[i])^(fy+a[i]);
}
a[fx]=fy;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
int x,y;
get_ans(); while(m--)
{
scanf("%d%d",&x,&y);
fun(x,y);
printf("%d\n",ans);
}
}
return ;
}
hdu-5683 zxa and xor (位运算)的更多相关文章
- HDU 5683 zxa and xor 暴力模拟
zxa and xor 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5683 Description zxa had a great interes ...
- hdu 5683 zxa and xor 暴力
zxa and xor Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Pro ...
- HDU 6186 CS Course (连续位运算)
CS Course Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU - 4810 - Wall Painting (位运算 + 数学)
题意: 从给出的颜料中选出天数个,第一天选一个,第二天选二个... 例如:第二天从4个中选出两个,把这两个进行异或运算(xor)计入结果 对于每一天输出所有异或的和 $\sum_{i=1}^nC_{n ...
- HDU 5014 Number Sequence(位运算)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5014 解题报告:西安网赛的题,当时想到一半,只想到从大的开始匹配,做异或运算得到对应的b[i],但是少 ...
- hdu 5491 The Next (位运算)
http://acm.hdu.edu.cn/showproblem.php?pid=5491 题目大意:给定一个数D,它的二进制数中1的个数为L,求比D大的数的最小值x且x的二进制数中1的个数num满 ...
- Go位运算
目录 &(AND) |(OR) ^(XOR) &^(AND NOT) << 和 >> & 位运算 AND | 位运算 OR ^ 位运算 XOR & ...
- HDU 3006 The Number of set(位运算 状态压缩)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3006 题目大意:给定n个集合,每个集合都是由大于等于1小于等于m的数字组成,m最大为14.由给出的集合 ...
- hdu 4739【位运算】.cpp
题意: 给出n个地雷所在位置,正好能够组成正方形的地雷就可以拿走..为了简化题目,只考虑平行于横轴的正方形.. 问最多可以拿走多少个正方形.. 思路: 先找出可以组成正方形的地雷组合cnt个.. 然后 ...
随机推荐
- Animation Spinner【项目】
https://github.com/vjpr/healthkick/blob/master/src/win/healthkick/ucSpinnerCogs.xaml 网上的例子,放在UserCon ...
- OC:内存管理、dealloc方法、copy知识点
属性的声明:使⽤@property声明属性 例如:@property NSString *name: 相当于@interface中声明了两个⽅法(setter.getter): 属性的实现:使⽤@s ...
- 扩展User增加部门字段
通过继承User<TEntity>类增加一个字段 /// <summary>用户信息</summary> [Serializable] [ModelCheckMod ...
- 关于request.getsession(true|false)
request.getSession(true):若存在会话则返回该会话,否则新建一个会话.request.getSession(false):若存在会话则返回该会话,否则返回NULL
- java/android线程池详解
一,简述线程池: 线程池是如何工作的:一系列任务出现后,根据自己的线程池安排任务进行. 如图: 线程池的好处: 重用线程池中的线程,避免因为线程的创建和销毁所带来的性能开销. 能有效控制线程池的最大并 ...
- ExtJs内的datefield控件选择日期过后的事件监听select
[摘要]: 选择时间过后我们为什么需要监听事件?一般有这样一种情况,那就是用于比较两个时间大小或者需要判断在哪个时间点上需要做什么样的操作.基于这样的种种情况,我们很有必要琢磨一下datefield控 ...
- VNC 抓取远程桌面
VNC (Virtual Network Computing)是虚拟网络计算机的缩写.VNC 是一款优秀的远程控制工具软件,由著名的 AT&T 的欧洲研究实验室开发的.VNC 是在基于 UNI ...
- openflashchart + flex
Hello openflashchart+flex的demo: http://blog.webasp.com.au/2009/06/open-flash-chart-as-a-swc/ http:// ...
- X431 元征诊断枪
X-431 Diagun是专门为汽车维修技师设计的诊断设备. 小巧的主机.强大的诊断功能.方便快捷的网上升级.一体化多功能接头,都是维修技师的首选.X-431 Diagun 是汽车维修技师的标准装备. ...
- VS2010: Microsoft.TeamFoundation.PowerTools.CheckinPolicies.ChangesetComments 未注冊
VS2010 缺少Team Foundation Server Power Tools 下载地址: http://visualstudiogallery.msdn.microsoft.com/c255 ...