# 101 条题解

• @ 2019-09-14 11:33:04

排个序就过了，需要XOR？

``````#include <iostream>
#include <algorithm>

using namespace std;

int n;
long long num[1000000]={0};

int main()
{
cin>>n;
int i;
for(i=0;i<n;i++)
{
cin>>num[i];
}
sort(num,num+n);
for(i=0;i<n;i+=2)
{
if(num[i]!=num[i+1])
{
cout<<num[i]<<endl;
break;
}
}
return 0;
}
``````
• @ 2017-04-30 14:20:11

你确定这是hash？？？

``````var
s, t:qword;
n, i:longint;
begin
s:=0;
for i:=1 to n do begin
s:=s xor t
end;
write(s)
end.

``````
• @ 2017-01-30 23:24:54

居然要输入挂了

• @ 2016-08-18 00:22:13

c++两行水过
#include<iostream>
using namespace std;long long a,b,c;main(){cin>>a;while(a--)cin>>b,c^=b;cout<<c;}

• @ 2016-02-28 11:09:47
• @ 2016-02-28 11:08:23
• @ 2016-02-28 11:10:46

啊，巧妙

• @ 2015-10-31 10:42:35

不给范围差评，裸map过

#include <iostream>
#include <map>
#include <cstdio>
using namespace std;

map<long long, long long> biao;
int n;

int main()
{
scanf ("%d", &n);
for (int i=1; i<=n; i++) {
long long temp;
scanf ("%lld", &temp);
if (!biao.count(temp)) biao[temp] = 0;
biao[temp]++;
}
for (map<long long, long long>::iterator i=biao.begin(); i!=biao.end(); ++i) {
if (i->second & 1) {
cout << i->first << endl;
return 0;
}
}
return 0;
}

• @ 2015-08-06 20:45:42

#include<cstdio>
using namespace std;

long long int ans=0, l;

int main()
{
int n;
scanf("%d",&n);
for(int i=1; i<=n; i++){
scanf("%lld",&l);
ans ^= l;
}
printf("%lld",ans);

return 0;
}
水一发~~~

• @ 2015-02-23 22:51:10

为何这样不行？卡在四号上了。
Program P1684;
Const MAX=10000000;
Var bl:array[1..MAX]of boolean;
n,o,i:longint;
begin
For i:=1 to n do
begin
bl[o]:=not bl[o];
end;
For i:=1 to MAX do
If bl[i] then break;
writeln(i);
end.
最后还是用了xor。。。

• @ 2015-02-01 20:00:01

### c++ code

#include<cstdio>
int main()
{
long long n,ans=0,t;
scanf("%lld",&n);
for (long long i=0;i!=n;++i)
{ scanf("%lld",&t); ans^=t; }
printf("%lld",ans);
return 0;
}

• @ 2014-10-15 00:21:35

program P1684;
var ll,l:int64;
i,n:longint;
begin
for i:=1 to n do
begin
end;
write(ll);
end.

• @ 2014-07-14 11:28:51

#include<cstdio>
#define IOFileName "P1684"
int n;
unsigned long long A=0,B;
int main(){
//freopen(IOFileName".in","r",stdin);
//freopen(IOFileName".out","w",stdout);
scanf("%d\n",&n);
for(int i=0;i<n;i++){
scanf("%I64u ",&B);
A^=B;
}
printf("%I64u\n",A);
}
357MS+248KB

• @ 2014-06-22 13:49:05

测试数据 #0: Accepted, time = 0 ms, mem = 604 KiB, score = 10

测试数据 #1: Accepted, time = 0 ms, mem = 608 KiB, score = 10

测试数据 #2: Accepted, time = 31 ms, mem = 608 KiB, score = 20

测试数据 #3: Accepted, time = 0 ms, mem = 612 KiB, score = 20

测试数据 #4: Accepted, time = 202 ms, mem = 608 KiB, score = 40

Accepted, time = 233 ms, mem = 612 KiB, score = 100

耗时233纪念，学习位运算的重要性2333333333

• @ 2013-11-07 08:42:48

我去！一水题废我过题率！var
j,n,m:int64;
i:longint；
begin
{assign(input,'sort.in');
assign(output,'sort.out');
reset(input);
rewrite(output);}
for i:=1 to n-1 do
begin
m:=m xor j;
end;
writeln(m);
{ close(input);
close(output); }
end.

• @ 2013-11-07 07:55:41

var
n,i:longint;
x,y:int64;
begin
for i:=2 to n do
begin
x:=x xor y;
end;
writeln(x);
end.
详见百度位运算

• @ 2013-11-03 17:46:47

这题百度百科位运算里面有的，神奇的XOR= =你值得拥有

• @ 2013-10-27 11:42:51

var a:array[1..10000000] of int64;
i,j,k,l,q,w,e,n,m:longint;
procedure qsort(l,r:longint);
var i,j,mid,e:int64;
begin
i:=l;j:=r;mid:=a[random(r-l+1)+l];
repeat
while a[i]<mid do inc(i);
while a[j]>mid do dec(j);
if i<=j then begin e:=a[i];a[i]:=a[j];a[j]:=e;inc(i);dec(j);end;
until i>j;
if i<r then qsort(i,r);
if j>l then qsort(l,j);
end;
begin
for i:=1 to n do read(a[i]);
qsort(1,n);
for i:=1 to n div 2+1 do
if a[i*2]<>a[i*2-1] then begin writeln(a[i*2-1]);halt;end;
end.

快排优化AC过

• @ 2012-10-07 21:04:00

本题提交2100次纪念。

(a xor b)xor b=a即为本题的精髓所在。

• @ 2010-03-06 22:33:25

program p1684(input,output);

var n,zs,zhi:int64;

i:longint;

begin

zs:=0;

for i:=1 to n do

begin

zs:=zs xor zhi;

end;

writeln(zs);

end.

闪过……………………

• @ 2010-02-28 11:40:16

/*

Vijos P1684

Time 2010/02/28

Lang C

*/

#include

main()

{

long long i,j,k,ans;

scanf("%I64d",&i);

ans = 0;

for (j=1;j

ID
1684

5

3027

940

31%

3