# | User | Rating |
---|---|---|
1 | jiangly | 3640 |
2 | Benq | 3593 |
3 | tourist | 3572 |
4 | orzdevinwang | 3561 |
5 | cnnfls_csy | 3539 |
6 | ecnerwala | 3534 |
7 | Radewoosh | 3532 |
8 | gyh20 | 3447 |
9 | Rebelz | 3409 |
10 | Geothermal | 3408 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 173 |
2 | adamant | 164 |
3 | awoo | 161 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | SecondThread | 152 |
8 | pajenegod | 146 |
9 | BledDest | 144 |
10 | Um_nik | 143 |
Name |
---|
Here is the AC version of your code: Submission A few changes I made: 1) In your submission, almost every variable was a long double. In practice, double precision is enough for passing test cases. So, I tried changing long double to double, but it still couldn't pass. Maybe it was because there were too many floating point operations, which I think are more complicated and expensive than integer operations. So, except for a couple of variables, I changed them all to long longs. 2) Removed all the statements outputting anything to stderr via cerr. This outputting of data also consumes the runtime.
This solution with doubles passes too!
@roll_no_1 thank you buddy....its a great help from your side as i see many solutions of this problem but not able to find what's the mistake i am doing. You explained it very well by making some of the changes in my code only supplement with a nice explanation.
I think you should also try to look at other faster solutions to see what improvement did they make, like in the one posted by ameya, I think the contestant reduced computational steps by doing a little more solving on paper by cancelling out common factors from the numerator and denominator, and that turned out to have a much better running time as compared to that of the optimizations that I made in your code.