Блог пользователя rishi_07

Автор rishi_07, история, 9 лет назад, По-английски

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

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

»
9 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by rishi_07 (previous revision, new revision, compare).

»
9 лет назад, скрыть # |
← Rev. 5  
Проголосовать: нравится +4 Проголосовать: не нравится

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.

»
9 лет назад, скрыть # |
 
Проголосовать: нравится -20 Проголосовать: не нравится

I can explain why the setprecision code gives WA but I have no idea about the printf . setprecision includes the number of digits before the decimal point also . So setting it to 9 + 6 should work.

»
9 лет назад, скрыть # |
 
Проголосовать: нравится +65 Проголосовать: не нравится

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