These are my codes for the problem Compression Algorithm of ACM ICPC 2018 online round.
I don't understand what is the problem with the first solution.
Note: The expected precision was 10^-6.
Image 1
Image 2
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
These are my codes for the problem Compression Algorithm of ACM ICPC 2018 online round.
I don't understand what is the problem with the first solution.
Note: The expected precision was 10^-6.
Image 1
Image 2
Название |
---|
Auto comment: topic has been updated by rishi_07 (previous revision, new revision, compare).
Well they say "Your answer will be considered correct if the absolute error is less than 10 - 6". With
printf("%.6lf")
there is possibility you will print something with error equal to 10 - 6 which is considered wrong.Hi, please check the first image. There I used setprecision(10). Still WA. This is not only my case, check this discussion on codechef Link
I can explain why the
setprecision
code gives WA but I have no idea about theprintf
. setprecision includes the number of digits before the decimal point also . So setting it to 9 + 6 should work.In this Link user swetankmodi claimed to have used setprecision(18) but still got WA.
This gave us AC
yes, but the solution posted by @bhishma uses long double but I used only double. Maybe that caused the issue?
You're wrong. From http://www.cplusplus.com/reference/iomanip/setprecision/
"Sets the decimal precision to be used to format floating-point values on output operations". Beside we submitted with setprecision(8) and it got accepted.
Actually my main language is Java so I might be wrong , but I have seen this issue in some old codeforces blog . In that case how can you explain this
There is a difference between cout<<fixed<<setprecision(10)<<x; and cout<<setprecision(10)<<x;
Example:
long double x=1000000000000.13232; cout<<fixed<<setprecision(10)<<x;
Output: 1000000000000.1323242188
long double x=1000000000000.13232; cout<<setprecision(10)<<x;
Output: 1e+12
If u dont use fixed and the number is reasonably large u might lose precision