Advertisement
Riposati

Untitled

Aug 2nd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 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.  
  50. long long B[max];
  51.  
  52. int main()
  53. {
  54.     long long ones,twos,x,i,n;
  55.  
  56.     scanf("%llu",&n);
  57.  
  58.     while(n!=0){
  59.  
  60.         ones = twos = 0;
  61.  
  62.         memset(B,0,n*sizeof(long long));
  63.  
  64.         for(i=0;i<n;i++){
  65.             scanf("%llu",&B[i]);
  66.         }
  67.  
  68.        for(i=0;i<n;i++){
  69.             x =  B[i];
  70.             ones ^= x;
  71.         }
  72.  
  73.         printf("%llu\n", ones );
  74.  
  75.         scanf("%llu",&n);
  76.     }
  77.  
  78.     return 0;
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement