Advertisement
rengetsu

Timus_1209

Jul 24th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. //Timus 1209
  2. #include <cmath>
  3. #include <iostream>
  4. using namespace std;
  5. bool Odin (long long n)
  6. {
  7.     double intPart;
  8.     double para = (1 + sqrt ( 8 * n -7)) /2;
  9.     double fractPart = modf(para, &intPart);
  10.  if (fractPart == 0.0)
  11.    return true;
  12.  else
  13.    return false;
  14. }
  15. int main()
  16. {
  17.     long long val;
  18.     long long num, i = 0;
  19.     cin >> num;
  20.     while (i < num)
  21.     {
  22.         cin >> val;
  23.         if (Odin (val))
  24.             cout << "1 ";
  25.         else
  26.             cout << "0 ";
  27.        
  28.         i++;
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement