hdu 5683 zxa and xor 暴力 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)


Problem Description
zxa had a great interest in exclusive disjunction(i.e. XOR) recently, therefore he took out a non-negative integer sequence ).
 
Input
The first line contains an positive integer 5
 
Output
For each test case, output in 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 = 0 , ch ;
    while( !( ( ch = getchar() ) >= '0' && ch <= '9' ) )
    {
        if( ch == EOF ) return 1 << 30 ;
    }
    res = ch - '0' ;
    while( ( ch = getchar() ) >= '0' && ch <= '9' )
        res = res * 10 + ( ch - '0' ) ;
    return res ;
}
int a[100010];
int main()
{
    int x,y,z,i,t;
    scanf("%d",&x);
    while(x--)
    {
        scanf("%d%d",&y,&z);
        for(i=1;i<=y;i++)
        scanf("%d",&a[i]);
        int sum=0;
        for(i=1;i<=y;i++)
        for(t=i+1;t<=y;t++)
        sum^=(a[i]+a[t]);
        while(z--)
        {
            int pos,change;
            scanf("%d%d",&pos,&change);
            for(i=1;i<=y;i++)
            {
                if(i!=pos)
                sum^=(a[i]+change)^(a[i]+a[pos]);
            }
            printf("%d
",sum);
            a[pos]=change;
        }
    }
    return 0;
}