|
|
back to boardWhy do I get TLE Test#9? subj, actually:(( i can't imagine the test where it doesn't work, tried to decrease eps - nothing better than TLE test #9... const eps=10e-8; var A,N,P:real; begin readln(N); A:=1; while abs((sqrt(sqr(2*A-1)+8*N))-(trunc(sqrt(sqr(2*A-1)+8*N))))>eps do A:=A+1; P:=(0.5-A+sqrt(sqr((2*A-1))+8*N)/2); writeln(A:0:0,' ',P:0:0); end Edited by author 29.04.2004 18:50 Edited by author 29.04.2004 19:06 Did you tried to increase eps? Re: Did you tried to increase eps? I did. Setting eps=10e-5 leads to WA test8, eps=10e-6 and 10e-7 - to WA test 9:(( and then 10e-8 come to TLE:(( Re: Try this you search for P from the divisors of 2*n less or equal to sqrt(2*n) then you verify if A is an integer A=(2*n/P-P+1)/2 you output the first solution because P is maxim(if you begin with sqrt(2*n) and go down) if you found no A integer you output N 1
Good Luck! Re: Try this thanks! that was the problem! the algorithm was almost the same, but I didn't manage the situation when nothing can be found:(( Edited by author 04.05.2004 15:04 |
|
|