|
|
back to boardIt accepted!!! Posted by ScaleS 17 Mar 2009 13:52 It accepted!!! Posted by ScaleS 17 Mar 2009 13:53 var n,i : word; p : real; function check(A : real):boolean; begin if frac((1+sqrt(8*A-7))/2) = 0.0 then check := true else check:=false; end; begin readln(n); for i:=1 to n do begin readln(p); if check(p) then write('1 ') else write('0 '); end; end. Re: It accepted!!! Yes, because the difference of correct answer (when you use -1) and your is 2, so there is no difference to use +1 or -1! )))) Re: It accepted!!! Posted by zAlogic 16 Dec 2010 15:20 frac((1+sqrt(8*A-7))/2) Where from it formula? What means? Re: It accepted!!! Could you take a look at my c++ code? I did the same as you but i never pass test #3 !! #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; } |
|
|