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 ...
随机推荐
- LinuxUSB驱动程序调试--009:编写应用程序---验证协议【转】
转自:http://biancheng.dnbcw.info/linux/257411.html [1] 如何编译X86下的 uBuntu APP---非常简单: gcc -o ...
- 【不知道是啥的NOIP模拟赛】网络入侵
题意是这样的: 给你一棵树,每个边有一个初始的0/1边权.你希望把它弄成一个给定的样子. 你每次可以选一条树链取反,然后问你最少要操作几次. ----------------------------- ...
- Django 内置模板标签和过滤器
一.内置模板标签 语法:{% %} autoescape : 是否转义,on或off作为参数,并确定自动转义是否在块内有效.该块以endautoescape结束 {% autoescape on % ...
- mysql -> 索引_07
索引与sql语句优化 压力测试对比
- Ubuntu 18.04安装MongoDB 4.0(社区版)
Ubuntu 18.04(虚拟机VirtualBox上),MongoDB 4.0, 听室友说,23点有世界杯决赛呢!可是,孤要写博文的啊!以记录这忙乱的下午和晚间成功安装了一个软件到Linux上.—— ...
- Oracle JDeveloper 10g 卡顿、花屏的解决方法
1.JDeveloper 10g花屏的解决办法: 在Win7或WinXP环境下,JDeveloper10g可能产生花屏现象,给开发者造成困扰,解决方法如下: 打开{JDEV_HOME}\jdev\bi ...
- TypeScript的配置文件 tsconfig.json
//tsconfig.json指定了用来编译这个项目的根文件和编译选项 { "compilerOptions": { //compilerOptions:编译选项,可以被忽略,这时 ...
- 多线程 or I/O复用select/epoll
1:多线程模型适用于处理短连接,且连接的打开关闭非常频繁的情形,但不适合处理长连接.线程模型默认情况下,在Linux下每个线程会开8M的栈空间,在TCP长连接的情况下,以2000/分钟的请求为例,几乎 ...
- LeetCode664. Strange Printer
There is a strange printer with the following two special requirements: The printer can only print a ...
- Linux学习笔记:crontab定时任务
通过crontab 命令,我们可以在固定的间隔时间执行指定的系统指令或 shell script脚本.时间间隔的单位可以是分钟.小时.日.月.周及以上的任意组合.这个命令非常适合周期性的日志分析或数据 ...