JohnnyTest's blog

By JohnnyTest, history, 6 years ago, In English

I tried solving 192A, which worked on my pc but when I uploaded on codeforces, the same code gave wrong output. I tried running it on Ideone, where also it produced right result.

codeforces submission

What I'm doing wrong?

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

| Write comment?
»
6 years ago, # |
  Vote: I like it +5 Vote: I do not like it

You are using long int which has different meanings on different plataforms, on windows it means a 32 int integer, while on linux it means a 64 bit integer.

When you are using a linux based plataform, as Ideone does, and I guess you too, you get the right answer, as if you were using a Windows plataform you would get the wrong answer.

Codeforces runs on a Windows machine and that's why you are getting Wrong Answer here.

My suggestion is that you should never use long int and always use either long long or int.

More information about it here: https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models