blankSpace's blog

By blankSpace, 11 years ago, In English

Hi, I was trying to solve 352C - Jeff and Rounding. My solution is 6873811. It's giving output as '0.000' in CF, even in Ideone.com, But in CodeBlocks IDE, it's giving correct answer '0.250'. Please help. What is the problem?

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
11 years ago, # |
  Vote: I like it +5 Vote: I do not like it

You are using both iostream and cstdio to handle input and output, remove line with ios::sync_with_stdio(0); and everything should be ok (I tried this on ideone.com and it wrote 0.250).

By the way you shouldn't call a function inside Abs, because for example Abs(solve(n+1,f+1) + ar[n]) will be translated to ((solve(n+1,f+1) + ar[n]) > 0? solve(n+1,f+1) + ar[n] : -(solve(n+1,f+1) + ar[n])) so function solve will be called twice, just saying, sometimes it can increase complexity a lot.