|
|
вернуться в форумc++ code always wrong in test #3, anyone who get accepted could help me? #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; } Re: c++ code always wrong in test #3, anyone who get accepted could help me? Послано junior 9 дек 2013 08:12 Think about how big can be 8 * n. Re: c++ code always wrong in test #3, anyone who get accepted could help me? accepted if you use long long instead long |
|
|