zxa and xor

Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Problem 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

After the first called function, this sequence is $\{4,2,3\}$, and $(4+2)\otimes(4+3)\otimes(2+3)=4$.

After the second called function, this sequence is $\{4,5,3\}$ and $(4+5)\otimes(4+3)\otimes(5+3)=6$.

After the third called function, this sequence is $\{4,5,6\}$ and $(4+5)\otimes(4+6)\otimes(5+6)=8$.

思路:通过位运算一些简单性质,暴力;(居然不会超时。。。)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000009
#define inf 999999999
#define esp 0.00000000001
//#pragma comment(linker, "/STACK:102400000,102400000")
int scan()
{
int res = , ch ;
while( !( ( ch = getchar() ) >= '' && ch <= '' ) )
{
if( ch == EOF ) return << ;
}
res = ch - '' ;
while( ( ch = getchar() ) >= '' && ch <= '' )
res = res * + ( ch - '' ) ;
return res ;
}
int a[];
int main()
{
int x,y,z,i,t;
scanf("%d",&x);
while(x--)
{
scanf("%d%d",&y,&z);
for(i=;i<=y;i++)
scanf("%d",&a[i]);
int sum=;
for(i=;i<=y;i++)
for(t=i+;t<=y;t++)
sum^=(a[i]+a[t]);
while(z--)
{
int pos,change;
scanf("%d%d",&pos,&change);
for(i=;i<=y;i++)
{
if(i!=pos)
sum^=(a[i]+change)^(a[i]+a[pos]);
}
printf("%d\n",sum);
a[pos]=change;
}
}
return ;
}

hdu 5683 zxa and xor 暴力的更多相关文章

  1. HDU 5683 zxa and xor 暴力模拟

    zxa and xor 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5683 Description zxa had a great interes ...

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

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

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

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

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

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

  5. hdu 4712 Hamming Distance(随机函数暴力)

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

  6. hdu 5277 YJC counts stars 暴力

    YJC counts stars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  7. HDU 5762 Teacher Bo (暴力)

    Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...

  8. hdu 4876 ZCC loves cards(暴力)

    题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...

  9. HDU 5442 Favorite Donut(暴力 or 后缀数组 or 最大表示法)

    http://acm.hdu.edu.cn/showproblem.php?pid=5442 题意:给出一串字符串,它是循环的,现在要选定一个起点,使得该字符串字典序最大(顺时针和逆时针均可),如果有 ...

随机推荐

  1. 【BZOJ3262】陌上花开 cdq分治

    [BZOJ3262]陌上花开 Description 有n朵花,每朵花有三个属性:花形(s).颜色(c).气味(m),又三个整数表示.现要对每朵花评级,一朵花的级别是它拥有的美丽能超过的花的数量.定义 ...

  2. python 多线程ping大量服务器在线情况

    需要ping一个网段所有机器的在线情况,shell脚步运行时间太长,用python写个多线程ping吧,代码如下: #!/usr/bin/python #coding=utf-8 ''' Create ...

  3. 在ListView中嵌套ListView的事件处理

    十分感谢此作者,以及作者的作者,让我卡了一星期的问题解决了!!http://blog.csdn.net/hutengfei0701/article/details/8956284谢谢http://my ...

  4. 05StuList.aspx(学生列表)

    05StuList.aspx  加载学生列表(前天代码) <%@ Page Language="C#" AutoEventWireup="true" Co ...

  5. FZU 1064 教授的测试(卡特兰数,递归)

    Problem 1064 教授的测试 Accept: 149 Submit: 364 Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Des ...

  6. 解决ORA-29857:表空间中存在域索引和/或次级对象 & ORA-01940:无法删除当前连接的用户问题 分类: oracle sde 2015-07-30 20:13 8人阅读 评论(0) 收藏

    今天ArcGIS的SDE发生了一点小故障,导致系统表丢失,所以需要重建一下SDE数据库,在删除SDE用户和所在的表空间过程中遇到下面两个ORA错误,解决方法如下: 1)删除表空间时报错:ORA-298 ...

  7. 拨开障目的叶,一览CMDB庐山真面目

    人们往往用"一叶障目,不见泰山"来形容一个人被局部现象所迷惑,看不到事物发展的整体脉络,从而做出一些不是十分正确的决策.小编觉得对于运维何尝不是这样呢. 大多数企业资产配置维护的现 ...

  8. Kafka丢失数据问题优化总结

    数据丢失是一件非常严重的事情事,针对数据丢失的问题我们需要有明确的思路来确定问题所在,针对这段时间的总结,我个人面对kafka 数据丢失问题的解决思路如下: 是否真正的存在数据丢失问题,比如有很多时候 ...

  9. loadrunner11的移动端性能测试之脚本优化

    测试步骤之脚本优化(Script) 看到这里,是不是疑惑录制好的脚本还需要优化吗,答案是肯定的. 优化概要 脚本优化包括插入注释(Comment),插入事务(Transaction),插入检查点(Ch ...

  10. ABP常见问题

    System.Data.SqlClient.SqlException (0x80131904): 'OFFSET' 附近有语法错误 解决方案:最新的ABP默认支持的是sql2012以上的版本,对于之前 ...