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

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

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.net/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!!!!

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

»
10 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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

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

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!)

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

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.

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

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