|
|
back to board#include <iostream> #include <cmath> bool isOne (long n) { double intPart; double para = (1 + sqrt ( 8 * n -7)) / 2; double fractPart = modf(para, &intPart); if (fractPart == 0.0) return true; else return false; } int main() { using namespace std; long value; long num, i = 0;
cin >> num; while (i < num) { cin >> value; if (isOne (value)) cout << "1 "; else cout << "0 "; i++; } return 0; } Think about how big can be 8 * n. accepted if you use long long instead long |
|
|