# | User | Rating |
---|---|---|
1 | Radewoosh | 3759 |
2 | orzdevinwang | 3697 |
3 | jiangly | 3662 |
4 | Benq | 3644 |
5 | -0.5 | 3545 |
6 | ecnerwala | 3505 |
7 | tourist | 3486 |
8 | inaFSTream | 3478 |
9 | maroonrk | 3454 |
10 | Rebelz | 3415 |
# | User | Contrib. |
---|---|---|
1 | adamant | 173 |
2 | awoo | 166 |
3 | nor | 165 |
4 | SecondThread | 164 |
5 | maroonrk | 162 |
5 | BledDest | 162 |
7 | Um_nik | 161 |
8 | -is-this-fft- | 149 |
9 | Geothermal | 146 |
10 | ko_osaga | 142 |
Name |
---|
Maybe it is because
pow
?I tried 'GNU C++17 (64)',and it returned
WA
too.Since the pow function uses and returns double value, with big numbers it can have a slight error, which gave you the WA verdict (You can see in your C++20 submission, the answers are only off by 16: 101159538130177904 vs 101159538130177920). I converted the types to long double and it got accepted: 173634899
For why did the C++17 solution get accepted, I have no idea. Maybe it's because of their different ways of compiling code?
More on this, you shouldn't use the pow function for integers for the same reason: Instead of pow(a, 2), it's recommended to use a*a. Your same code using a*a: 173635181
I think this is precisely what you are experiencing.
Yes. Floating point numbers work in mysterious ways in C++(32 bit). With C++(64 bit) they behave a lot more sane.
For example submitting
gives AC with C++17(32 bit) 173799443.
While submitting
gives WA with C++17(32 bit) 173799415.
Dealing with floating point numbers in C++(32 bit) almost feels like quantum physics. Just looking at them can change the result.