2019.7.24 school test analysis + problem solution

T1 mines

 

Topic is very simple, that is, the number of which seek only appears once on it oh ~

I started thinking of a bucket row (which is the most simple of the most simple idea it ~), but the space is open 2 32 will certainly be deep-fried, but time will seem to blow up.

Then the left ych big brother whispered sentence: "Algorithms have to change."

Ah, really wanted a change in algorithms, then I think the new algorithm must not have open array, data can be directly losers out the answer that is!

Then do not know how to think of simultaneous input zhx when talking about game theory will ...... (some strange things) XOR up is the answer, this is not just with new algorithms like my ideal thing?

XOR XOR? Hey, I thought that the end of June exam a man named [concert] Dara-collapse right on the cancer question, to the above two tips:

Yes, two of the same number of XOR together is 0!

So we can all have different number or up, as long as there are two identical becomes 0, then what is left is that not a single drop of a thing?

So the code came out duck ~:

#include<iostream>
#include<cstdio>
using namespace std;
int read()
{
    char ch=getchar();
    int a=0,x=1;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') x=-x;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        a=(a<<1)+(a<<3)+(ch-'0');
        ch=getchar();
    }
    return a*x;
}
int n,x,ans;
int main()
{
    n=read();
    for(int i=1;i<=n;i++)
    {
        x=read();
        ans^=x;                //求每个数的异或和 
    }
    printf("%d",ans);
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/xcg123/p/11237083.html