Advertisement
Riposati

Untitled

Aug 2nd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 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.         mapa.insert(pair<long long,long long>(i+1,0));
  19.     }
  20.  
  21.     for(i=0;i<n;i++){
  22.  
  23.         scanf("%llu",&aux);
  24.  
  25.         mapa.find(aux)->second++;
  26.     }
  27.  
  28.     long long resp = 0;
  29.  
  30.      for (map<long long,long long>::iterator it=mapa.begin(); it!=mapa.end(); ++it)
  31.      {
  32.          if(it->second % 2 != 0){
  33.             resp = it->first;
  34.          }
  35.      }
  36.  
  37.     printf("%llu\n",resp);
  38.  
  39.     scanf("%llu",&n);
  40.   }
  41.   return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement