gchandel6's blog

By gchandel6, 12 years ago, In English

Hello everyone , i am new to codeforces and as i was solving my first problem "SPREADSHEETS" from codeforces beta round #1 , which is showing wrong_answer in test1 , while in my g++ compiler its giving correct output for that case ...please anyone help....why is this happening??

THIS IS LINK TO MY CODE::::

http://ideone.com/25zz0L

TEST CASE : 2 R23C55 BC23

ANSWER : BC23 R23C55

ON MY COMPUTER : BC23 R23C55

CODEFORCES SHOWING : BC23 R23C54

Why is codeforces showing 54 instead of 55?

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

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

You should forget about pow when you don't really need it. Use your function and the outcome will be WA on test #6.

BTW, can anybody explain why does this happen? Recently, I read a blog about a mistake and I really want to know why...

  • »
    »
    12 years ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    pow when used, returns a floating point number which is slightly less but very close to the actual answer. So it's always a good idea to do int(ceil(float(pow(x,y)))). Or the best method would be to do fast exponentiation by manually creating your exponentiation function..