Advertisement
andreisophie

Colectie

Sep 18th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <bitset>
  4. #define NMAX 9000001
  5.  
  6. using namespace std;
  7.  
  8. ifstream in("colectie.in");
  9. ofstream out("colectie.out");
  10.  
  11. bitset <NMAX> f1;
  12. bitset <NMAX> f2;
  13. int i,n,input,ap;
  14.  
  15. void Citire()
  16. {
  17.     in>>n;
  18.     for(i=1; i<=n; i++)
  19.     {
  20.         in>>input;
  21.         if(f1[input]==0)
  22.             f1[input]=1;
  23.         else
  24.         {
  25.             if(f2[input]==0)
  26.                 f2[input]=1;
  27.         }
  28.     }
  29. }
  30.  
  31. void Afisare()
  32. {
  33.     for(i=1; i<=n; i++)
  34.     {
  35.         if(f1[i]==1 && f2[i]==0)
  36.             ap++;
  37.     }
  38.     out<<ap;
  39. }
  40.  
  41. int main()
  42. {
  43.     Citire();
  44.     Afisare();
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement