HDU 5683 zxa and xor 暴力模拟
zxa and xor
题目连接:
http://acm.hdu.edu.cn/showproblem.php?pid=5683
Description
zxa had a great interest in exclusive disjunction(i.e. XOR) recently, therefore he took out a non-negative integer sequence a1,a2,⋯,an of length n.
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).
Input
The first line contains an positive integer T, represents there are T test cases.
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⋅104,1≤m≤2⋅104,0≤ai,y≤109,1≤x≤n,1≤∑n,∑m≤105
Output
For each test case, output in m lines, the i-th line a positive integer, repersents the return value for the i-th called function.
Sample Input
1
3 3
1 2 3
1 4
2 5
3 6
Sample Output
4
6
8
Hint
题意
zxa最近对按位异或(exclusive disjunction)产生了极大的兴趣,为此他拿出了一个长度为\(n\)的非负整数序列\(a_1,a_2,\cdots,a_n\)。
zxa觉得这样太单调了,于是他定义了一种方法\(funct(x,y)\),表示将\(a_x\)不可逆转地修改为\(y\)后计算\(\otimes_{1\leq i < j\leq n}{(a_i+a_j)}\)作为该方法的返回值。
zxa很好奇,如果他对这个序列调用\(m\)次这样的方法,那么每次得到的返回值分别是多少,你能帮助他吗?
题解:
模拟就好了
题目怎么说的,就怎么做,这样就能AC
吃惊!
总而言之,从出题的意义上来说,这道题太蠢了……
代码
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e4+6;
int a[maxn],ans,n,m;
void solve()
{
scanf("%d%d",&n,&m);
ans=0;
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)
ans^=(a[i]+a[j]);
while(m--)
{
int x,y;scanf("%d%d",&x,&y);
for(int i=1;i<x;i++)ans^=(a[x]+a[i])^(y+a[i]);
for(int i=x+1;i<=n;i++)ans^=(a[x]+a[i])^(y+a[i]);
a[x]=y;
printf("%d\n",ans);
}
}
int main()
{
int t;scanf("%d",&t);
while(t--)solve();
return 0;
}
HDU 5683 zxa and xor 暴力模拟的更多相关文章
- hdu 5683 zxa and xor 暴力
zxa and xor Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Pro ...
- HDU 5486 Difference of Clustering 暴力模拟
Difference of Clustering HDU - 5486 题意:有n个实体,新旧两种聚类算法,每种算法有很多聚类,在同一算法里,一个实体只属于一个聚类,然后有以下三种模式. 第一种分散, ...
- hdu-5683 zxa and xor (位运算)
题目链接: zxa and xor Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- bnuoj 20832 Calculating Yuan Fen(暴力模拟)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=20832 [题意]: 给你一串字符串,求一个ST(0<ST<=10000),对字符串中字符 ...
- POJ 1013 小水题 暴力模拟
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35774 Accepted: 11 ...
- hdu_1006 Tick and Tick(暴力模拟)
hdu1006 标签(空格分隔): 暴力枚举 好久没有打题了,退队了有好几个月了,从心底不依赖那个人了,原来以为的爱情戏原来都只是我的独角戏.之前的我有时候好希望有个人出现,告诉自己去哪里,做什么,哪 ...
- UVA.12716 GCD XOR (暴力枚举 数论GCD)
UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...
- HDU 2920 分块底数优化 暴力
其实和昨天写的那道水题是一样的,注意爆LL $1<=n,k<=1e9$,$\sum\limits_{i=1}^{n}(k \mod i) = nk - \sum\limits_{i=1}^ ...
- hihoCoder #1871 : Heshen's Account Book-字符串暴力模拟 自闭(getline()函数) (ACM-ICPC Asia Beijing Regional Contest 2018 Reproduction B) 2018 ICPC 北京区域赛现场赛B
P2 : Heshen's Account Book Time Limit:1000ms Case Time Limit:1000ms Memory Limit:512MB Description H ...
随机推荐
- 转载-struts中logic标签使用
Struts中Logic逻辑标签的作用及用法 Struts中Logic逻辑标签的作用及用法 2006年10月18日 星期三 21:34 Terry原创,转载请说明作者及出处 Logic标签大部分的功能 ...
- 安装Visual Studio Scrum 1.0过程模板
近几年里,Scrum变成了相当流行的软件开发方法学.因为它轻量.可迭代且快速等优点,以致于在敏捷开发中极受欢迎.微软甚至将TFS2010自带的MSF Agile5.0过程模板做得像Scrum,开发者们 ...
- [HBase] 服务端RPC机制及代码梳理
基于版本:CDH5.4.2 上述版本较老,但是目前生产上是使用这个版本,所以以此为例. 1. 概要 说明: 客户端API发送的请求将会被RPCServer的Listener线程监听到. Listene ...
- Flask:cookie 和 session (0.1)
Windows 10家庭中文版,Python 3.6.4,Flask 1.0.2 Cookie是什么?有什么用? 某些网站为了辨别用户身份.进行 session 跟踪而储存在用户本地终端上的数据(通常 ...
- Windows Phone 8 获取设备名称
通过使用Microsoft.Phone.Info.DeviceStatus类,我们可以获取设备的一些信息,如设备厂商,设备名称等.通过Microsoft.Phone.Info.DeviceStatus ...
- ThinkPHP联表查询
$list = db($pnav['ename']) -> field('a.*,b.name as pname') ->alias('a') -> join('sbl_nav b' ...
- javaweb笔记二
web服务器:实现服务器的开启,监听端口,接收客户端请求,产生响应.响应信息只能是静态的HTML,缺乏灵活性.web容器:是辅助应用的一种方式,是为了解决web服务器缺陷而产生的.可以将请求信息处理完 ...
- Kubernetes 部署kafka ACL(单机版)
一.概述 在Kafka0.9版本之前,Kafka集群时没有安全机制的.Kafka Client应用可以通过连接Zookeeper地址,例如zk1:2181:zk2:2181,zk3:2181等.来获取 ...
- Asp.net MVC NPOI导出Excel
public class NpoiMemoryStream : MemoryStream { public NpoiMemoryStream() { AllowClose = true; } publ ...
- lr11录制时报“Request Connection: Remote Server @ 0.0.0.0:1080 (Service=?) NOT PROXIED! )”解决方法
在录制脚本的时候出现如下现象: 解决方法: LoadRunner录制脚本时出现:Unable to connect to remote server),有事件没有脚本的问题 1.首先要查看IE浏览 ...