|
|
Could you please give me some tests? Edited by author 31.10.2013 02:11 Try this testcase: 1000000000 1000000000 -1000000000 The answer is 5. My program uses unsigned int64 in C++, and gets overflow on this case. What's the answer for this test? 3 1 1 1 25000000 10001 1 1 -90000 -999890001 I'm using BigInteger arithmethic and BinSearch, but still WA2... 1) D<0: answer 1 2) sum(0, k-1):f(x1+i) -> as result, we need to compare a^2*(2*k-1)^2 and 9*D what's wrong? Edited by author 03.04.2013 18:40 Output of my (AC) program: 1 2 190523 I used standard C++ double type to solve it - it seems there're no difficult tests that fail it (or such tests are just impossible) BTW, for the case (2) my solution considers two different cases I found bug in logic, but still... 1) D<0: 1 2) a) sum(0, k-1):f(x0+0.5+i) -> as result, we need to compare F(x0+0.5) and a*(k-1)/2.0 + a*(k-1)*(2*k-1)/6.0 -> then multiply by 2 b) sum(0, k-1):f(x0+i) -> as result, we need to compare F(x0)/2.0 and a*(k-1)*(2*k-1)/6.0 -> then multiply by 2 and substract 1 Some more tests: 7 1 1 0 1 6 -9 1 0 -1 1 1000000000 -1000000000 1000000000 -1000000000 -1000000000 1234 987654321 -987654321 100000000 987654321 -987654321 can anybody explain me how to use reals with big range like 10^18 or 10^19 more precisely in pascal? If you need real numbers with best affordable precision - use long double ("extended" in pascal). Edited by author 06.01.2013 23:12 I knew the solution was k=1 or trunc((1+12*b*b/(a*a)-3*c/a)). but i could not take precision. If you need real numbers with best affordable precision - use long double ("extended" in pascal). F**k, spoiler =( Then you don't need real numbers here - long long (int64 in Pascal) is enough to solve it why the answer to the first sample is 2 I THANK IT IT 1 because let x=1 then f(x)=0 so it only takes 1 sec I misunderstood the statement. But why WA1? f**king #ifndef ONLINE_JUDGE Sorry for stupid questions. Will the total dist travelled after k seconds be f(x)+f(x+1)+f(x+2)+...f(x+k-1) or it will be f(x+k-1) just? Thanks! f(x)+f(x+1)+f(x+2)+...f(x+k-1) |
|
|