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

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

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?

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

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

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