AlenAntonelli

TIMUS 1 10 100 1000_Alen

May 20th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. ///1209. 1, 10, 100, 1000...
  2. #include <iostream> ///Antonelli Alen Gabriel, E.E.S.T.N°5 MERLO, 5to 3ra
  3. #include <algorithm>
  4. #include <vector>
  5. using namespace std;
  6. int main ()
  7. {///2147483647
  8.     int n;
  9.     cin>>n;
  10.     vector <unsigned long> p (65537, 0), k (n, 0);
  11.     for (long i=1; i<p.size(); i++)
  12.         p[i]=p[i-1]+i;
  13.     for (int i=0; i<n; i++)
  14.         cin>>k[i];
  15.     cout<<endl;
  16.     for (int i=0; i<n; i++)
  17.     {
  18.         if (  binary_search(p.begin(), p.end(), k[i]-1)  )
  19.             cout<<"1 ";
  20.         else
  21.             cout<<"0 ";
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment