题解

101 条题解

  • 2
    @ 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;
    }
    
  • 0
    @ 2017-04-30 14:20:11

    你确定这是hash???

    var
      s, t:qword;
      n, i:longint;
    begin
      readln(n);
      s:=0;
      for i:=1 to n do begin
        read(t);
        s:=s xor t
      end;
      write(s)
    end.
    
    
  • 0
    @ 2017-01-30 23:24:54

    居然要输入挂了

  • 0
    @ 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;}

  • 0
    @ 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;
    }

  • 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;
    }
    水一发~~~

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

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

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

    此题数据范围略大,要用64位整形储存,全部xor一边后即是答案

    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;
    }

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

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

  • 0
    @ 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

  • 0
    @ 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

  • 0
    @ 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);}
    readln(n);
    read(m);
    for i:=1 to n-1 do
    begin
    read(j);
    m:=m xor j;
    end;
    writeln(m);
    { close(input);
    close(output); }
    end.

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

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

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

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

  • 0
    @ 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
    readln(n);
    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过

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

    本题提交2100次纪念。

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

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

    program p1684(input,output);

    var n,zs,zhi:int64;

    i:longint;

    begin

    readln(n);

    zs:=0;

    for i:=1 to n do

    begin

    read(zhi);

    zs:=zs xor zhi;

    end;

    writeln(zs);

    end.

    闪过……………………

  • 0
    @ 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
分类
数据结构 | Hashing 点击显示
标签
递交数
3033
已通过
941
通过率
31%
被复制
5
上传者