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 暴力模拟的更多相关文章

  1. hdu 5683 zxa and xor 暴力

    zxa and xor Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Pro ...

  2. HDU 5486 Difference of Clustering 暴力模拟

    Difference of Clustering HDU - 5486 题意:有n个实体,新旧两种聚类算法,每种算法有很多聚类,在同一算法里,一个实体只属于一个聚类,然后有以下三种模式. 第一种分散, ...

  3. hdu-5683 zxa and xor (位运算)

    题目链接: zxa and xor Time Limit: 16000/8000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Othe ...

  4. bnuoj 20832 Calculating Yuan Fen(暴力模拟)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=20832 [题意]: 给你一串字符串,求一个ST(0<ST<=10000),对字符串中字符 ...

  5. POJ 1013 小水题 暴力模拟

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35774   Accepted: 11 ...

  6. hdu_1006 Tick and Tick(暴力模拟)

    hdu1006 标签(空格分隔): 暴力枚举 好久没有打题了,退队了有好几个月了,从心底不依赖那个人了,原来以为的爱情戏原来都只是我的独角戏.之前的我有时候好希望有个人出现,告诉自己去哪里,做什么,哪 ...

  7. UVA.12716 GCD XOR (暴力枚举 数论GCD)

    UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...

  8. HDU 2920 分块底数优化 暴力

    其实和昨天写的那道水题是一样的,注意爆LL $1<=n,k<=1e9$,$\sum\limits_{i=1}^{n}(k \mod i) = nk - \sum\limits_{i=1}^ ...

  9. 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 ...

随机推荐

  1. jmeter,测登录,要不要过滤掉JS,CSS等请求?感觉过滤掉了压出来的数据就不真实?

    首先,我们来明确下你的性能测试目的,你的目的是服务端的性能还是前端的性能.这两用目的所涉及到的测试场景和工具等方法是不一样的.1.我们先来谈谈服务端的性能.一般的web产品,像css, jpeg等这种 ...

  2. 2018Java开发面经(持续更新)

    不要给自己挖坑!!!不要给自己挖坑!!!不要给自己挖坑!!!如果面试官只是问你了解xxx吗,如果不是很了解,就直接说不知道,不要说知道,不然面试官深问再不知道就印象很不好! 处女面送给了头条(北京)日 ...

  3. Monkeyrunner的相关总结

    1.1  monkeyrunner API 主要包括三个模块1.MonkeyRunner:这个类提供了用于连接monkeyrunner和设备或模拟器的方法,它还提供了用于创建用户界面显示提供了方法.2 ...

  4. 正则表达式基础->

    描述:(grep) 正则表达式是一种字符模式,用于在查找过程中匹配指定的字符.在大多数程序里,正则表达式都被置于两个正斜杠之间,它匹配被查找的行中任何位置出现的相同模式 基础正则表达式 正则表达式 描 ...

  5. linux编译警告 will be initialized after

    http://blog.chinaunix.net/uid-17019762-id-3152012.html 作为一个有强迫症的人,实在是受不了 warning 的存在 这个warning是由于初始化 ...

  6. Java WebService Axis 初探

    最近在学习WebService 开始了: 一:服务端的编写与发布 1. 工具准备: java的开发环境(这里就不多说了).   axis2官网上下载最新的就可以了(我这里用的是axis2-1.4.1- ...

  7. tf.reduce_sum函数

    >>> x=[[1,2,3],[23,13,213]] >>> xx=tf.reduce_sum(x) >>> sess.run(xx) 255 ...

  8. luogu P3393 逃离僵尸岛

    luoguP3393逃离_僵尸岛_ 一道洛谷不知道哪门子月赛的题 可以用此题来练习最短路算法 SPFA和dijkstra的练习题(关于Floyed,他死了 思路: 本题是最短路板子. 首先就是建立虚点 ...

  9. css边框内凹圆角,解决优惠券的边框问题

    关于css边框内凹圆角,找了好久才找到的 <html <head> <title>无标题页</title> <style> body{ backg ...

  10. gtk+学习笔记(八)

    框架(Frames)可以用于在盒子中封装一个或一组构件,框架本身还可以有一个标签.标签的位置和盒子的风格可以灵活改变. 框架可以用下面的函数创建: GtkWidget *gtk_frame_new( ...