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⋅104,1≤m≤2⋅104,0≤ai,y≤109,1≤x≤n,1≤∑n,∑m≤105
3 3
1 2 3
1 4
2 5
3 6
6
8
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 暴力的更多相关文章
- 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/Othe ...
- 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}^ ...
- hdu 4712 Hamming Distance(随机函数暴力)
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- hdu 5277 YJC counts stars 暴力
YJC counts stars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- HDU 5762 Teacher Bo (暴力)
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
- hdu 4876 ZCC loves cards(暴力)
题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...
- HDU 5442 Favorite Donut(暴力 or 后缀数组 or 最大表示法)
http://acm.hdu.edu.cn/showproblem.php?pid=5442 题意:给出一串字符串,它是循环的,现在要选定一个起点,使得该字符串字典序最大(顺时针和逆时针均可),如果有 ...
随机推荐
- 【BZOJ5101】[POI2018]Powód 并查集
[BZOJ5101][POI2018]Powód Description 在地面上有一个水箱,它的俯视图被划分成了n行m列个方格,相邻两个方格之间有一堵厚度可以忽略不计的墙,水箱与外界之间有一堵高度无 ...
- 最小费用流判负环消圈算法(poj2175)
Evacuation Plan Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3384 Accepted: 888 ...
- (转)梯度下降法及其Python实现
梯度下降法(gradient descent),又名最速下降法(steepest descent)是求解无约束最优化问题最常用的方法,它是一种迭代方法,每一步主要的操作是求解目标函数的梯度向量,将当前 ...
- 持续集成之jenkins2
ip 什么是持续集成 没有持续集成 持续集成最佳实践 持续集成概览 什么是Jenkins Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开 ...
- 用了快1年的MacBook Pro遇到的硬件问题
去年11月7日买的MacBook Pro,到目前快1年了,遇到了3个硬件问题(之前用了5年的Thinkpad在5年内未出现任何硬件问题): 1. 有一次MacBook放在背包中,背包拎在手上落在地上, ...
- MySQL逗号分割字段的列转行
前言: 由于很多业务表因为历史原因或者性能原因,都使用了违反第一范式的设计模式.即同一个列中存储了多个属性值(具体结构见下表). 这种模式下,应用常常需要将这个列依据分隔符进行分割,并得到列转行的结果 ...
- Oracle性能优化之oracle中常见的执行计划及其简单解释
一.访问表执行计划 1.table access full:全表扫描.它会访问表中的每一条记录(读取高水位线以内的每一个数据块). 2.table access by user rowid:输入源ro ...
- Modulo operation
Modulo operation - Wikipedia https://en.wikipedia.org/wiki/Modulo_operation https://baike.baidu.com/ ...
- ubuntu low graphic mode---disable docker -self start.
--------- /etc/default/docker.conf-----设置启动参数. /etc/init/docker.conf------------不好使(only mysql) star ...
- Vanish/squid
http://www.yl1001.com/article/5291411898652918.htm HTTP加速 简单的说,在本次测试中,Varnish将来自80的请求转发到后端的nginx8080 ...