rkb_rd's blog

By rkb_rd, 18 months ago, In English

During solving this problem, when i submitted the following code with c++ setprecision function i got Wrong answer on test 5.

Code

And later the following one got accepted without setprecision.

Code

My question is, what i did wrong in the first one?

Thank You...

Upd: Got the error. Should use long double instead double

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
18 months ago, # |
Rev. 2   Vote: I like it -6 Vote: I do not like it

.

»
18 months ago, # |
  Vote: I like it +1 Vote: I do not like it

I can't see the actual wrong answer message so this is just guesses. It could be that when you're dividing by 2 in the first solution, ans is so large that floating point precision is too much of a problem (i.e. rounds it closer to .4 or .6 instead of .5)