kishuagarwal's blog

By kishuagarwal, history, 7 years ago, In English

Can anyone look into this code Python Code and tell why I am getting Runtime Error. Same code when written in C is passing. C Code

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Run your code in the custom test with the test case it fails. The error it throws is that in your for loop, i needs to be a long, but Python considers it an int. Therefore, you have an overflow.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    @Saat, I tried running the same code on my personal machine and on ideone.com on the same test case it was failing. It is running fine there.

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      There are differences in the interpreters. You can see that Codeforces is full of people complaining about RTE in cpp due to undefined behavior. I guess that there is the same problem in Python.