Advertisement
Riposati

Untitled

Aug 19th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /*map<long long,long long>mapa;
  6.  
  7. int main()
  8. {
  9.   long long i,n,aux;
  10.  
  11.   scanf("%llu",&n);
  12.  
  13.   while(n!=0){
  14.  
  15.     mapa.clear();
  16.  
  17.     for(i=0;i<n;i++){
  18.  
  19.         scanf("%llu",&aux);
  20.  
  21.         mapa.insert(pair<long long,long long>(aux,0));
  22.         mapa.find(aux)->second++;
  23.     }
  24.  
  25.     /*for (map<long long,long long>::iterator it=mapa.begin(); it!=mapa.end(); ++it)
  26.      {
  27.  
  28.             cout<<"chave = "<<it->first<<" "<<" valor = "<<it->second<<"\n";
  29.  
  30.      }*/
  31.  
  32.     /*long long resp = 0;
  33.  
  34.      for (map<long long,long long>::iterator it=mapa.begin(); it!=mapa.end(); ++it)
  35.      {
  36.          if(it->second % 2 != 0){
  37.             resp = it->first;
  38.          }
  39.      }
  40.  
  41.     printf("%llu\n",resp);
  42.  
  43.     scanf("%llu",&n);
  44.   }
  45.   return 0;
  46. }*/
  47.  
  48. #define max 100000
  49. #define gc getchar_unlocked
  50.  
  51. long long B[max];
  52.  
  53. void scanint(long long &x){
  54.  
  55.     register long long c = gc();
  56.  
  57.     x = 0;
  58.  
  59.     for(;(c < 48 || c>57);c = gc());
  60.  
  61.     for(;c>47 && c <58; c = gc()){
  62.  
  63.         x = (x<<1) + (x<<3) + c - 48;
  64.     }
  65. }
  66.  
  67. int main()
  68. {
  69.     long long ones,twos,x,i,n;
  70.  
  71.  
  72.     scanf("%llu",&n);
  73.  
  74.     while(n!=0){
  75.  
  76.         ones = twos = 0;
  77.  
  78.         memset(B,0,n*sizeof(long long));
  79.  
  80.  
  81.         for(i=0;i<n;i++){
  82.             //scanf("%llu",&B[i]);
  83.  
  84.             scanint(B[i]);
  85.         }
  86.  
  87.        for(i=0;i<n;i++){
  88.             x =  B[i];
  89.             ones ^= x;
  90.         }
  91.  
  92.         printf("%llu\n", ones );
  93.  
  94.         scanf("%llu",&n);
  95.     }
  96.  
  97.     return 0;
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement