What is wrong in question GOHAN (NSIT_Div2)

Question GOHAN

Contest - NSIT(Div 2) rated contest.

What is the need of “fixed” for printing the final answer in this question?

cout<<setprecision(10)<<1-rrc/(4*l); has not been passed.

But,

cout<<fixed<<setprecision(10)<<1-rrc/(4*l); is passed.

Can anyone explain the importance of fixed?
Thank you.

Suppose your answer is 120
case 1:- you use fixed

answer will be printed as 120.000…(upto specified precision)

case 2:- you don’t use

answer will be printed as 120

Got your point, but both the output should give AC.
What was wrong with the judge then? @admin

Try the test case:

1
100000 1 100000 9999999

With “.6f”, it produces output:

-249999999999999.000000

Otherwise, it produces output:

-2.5e+14

Magnitude of error is greater than 1e-2.

1 Like

@alpha_killer as @sarthakmanna explains, not using ‘fixed’ causes the output to be printed in scientific notation, which not all judges accept, or if accepted may be way off than the desired degree of accuracy.