aa19081995's blog

By aa19081995, history, 9 years ago, In English

this weird thing happened with me during a recent DIV 2 contest Codeforces Round #308 (Div. 2) . i submitted this code http://ideone.com/Jdt8it for problem http://codeforces.com/contest/552/problem/B and as u can see for input 99 i am getting the out 189 but here is my codeforces submission #11648222 and here it shows that for test case #4 which is actually input=99 my code is giving output 190. i tried running this same code on codechef IDE and there also with input 99 i got 189. so, can someone please help me why this weird thing might be happening!!!!

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

| Write comment?
»
9 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

For add up : Attached screenshots of his solution output on CodeForce, Ideone and Codechef IDE.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

also your code for test = 100 gives 192 on my computer whereas I've got WA with your code on this test! (it have outputted 193!)

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

anyway, casting the function "pow" to "long long int" is not a good choice, instead, you can pre calculate the powers of ten before the main part of your code, here I've changed your code a bit and it've got accepted.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

it is because pow function does not work well on it. look at this. : http://ideone.com/ypEdeI I submitted it and it worked