# | User | Rating |
---|---|---|
1 | tourist | 3682 |
2 | ecnerwala | 3603 |
3 | Benq | 3549 |
4 | Radewoosh | 3494 |
5 | Petr | 3452 |
6 | ksun48 | 3413 |
7 | maroonrk | 3406 |
8 | Miracle03 | 3314 |
9 | scott_wu | 3313 |
10 | Um_nik | 3299 |
# | User | Contrib. |
---|---|---|
1 | 1-gon | 214 |
2 | Errichto | 189 |
3 | awoo | 188 |
4 | rng_58 | 187 |
5 | SecondThread | 186 |
6 | Um_nik | 179 |
7 | Ashishgup | 177 |
8 | maroonrk | 173 |
9 | vovuh | 172 |
9 | antontrygubO_o | 172 |
Name |
---|
try submitting in GNU G++17 9.2.0 (64 bit, msys 2)
Already tried -_-
then you shouldve noticed that its failing on a different testcase which gave WA on my machine too
108420664
ll -> long double. I really don't know how and why it is. Never even tried to learn really deep in floating point math because almost always there is way with absolutely understandable integer math.
It is a precision error. If you add "two ifs" to correct the result of the division between the logs, we will be accepted. https://codeforces.com/contest/1485/submission/108425917
What is strangest for me are different machines computing the rounding of floating pointers in different ways.
Either way, we depend on luck when doing operations that are very sensitive to rounding floating pointers (as in this case, that $$$\frac{a}{b} = 3.9999999$$$ is completely different from $$$\frac{a}{b} = 4$$$).
The explanation is that floating point numbers work differently in 32 bit vs 64 bit. I have a blog about it . Explanation to weird/strange floating point behaviour in C++
In short, back when 32 bit used to be a thing, the processor didn't directly support float and double calculations. All it supported was (80 bit) long doubles. On top of this, someone had the genius idea of getting extra precision by keeping floats and doubles as long doubles up to the point where they are stored in memory.
The issue is that you can't control where the conversion happens. This leads to weird behaviour like this.
Good thing is that if you use 64 bit g++, then all of these problems are gone. Floats will act like floats and doubles will act like doubles. No more hidden excess precision.
My guess is that you locally compiled with 64 bit, but submitted on cf with 32 bit.