Submit the same code with Pypy3 and Python3 got different results on sgu-113

Правка en1, от -14, 2019-10-29 15:05:44

Today when I am trying to solve acmsguru-113 with PyPy3 (because when I was submitting Python3, CodeForces noticed me that "Almost always, if you send a solution on PyPy, it works much faster"), I got lots of Wrong Answer on test 1. I thought it impossible because it's actually a very simple problem and I have confidence in my code. Then I rewrite it in C++, and with identical implementation it's accepted.

Then I realize there may be problems in input format, so I write a tokenizer to solve this problem. However, it's just another WA on 1.

After one hour of struggling in finding bugs and differences, I found nothing but submitted it with Python3 — and it's a accepted!

Here are the python code with tokenizer, and submissions with this code : 63721685 63721667

now_token = input().split()
now_token.reverse()
def nxt_token():
    global now_token
    if len(now_token) > 0:
        ret = now_token[-1]
        now_token.pop()
        return ret
    else:
        now_token = input().split()
        now_token.reverse()
        return nxt_token();

n = int(nxt_token())
while n > 0:
    n -= 1
    x = int(nxt_token())
    ans = False
    i = 2
    while i * i <= x:
        if x % i == 0:
            y = x // i
            ans = (y > 1)
            j = 2
            while j * j <= y:
                if y % j == 0:
                    ans = 0
                    break
                j += 1
            break
        i += 1
    if ans:
        print("Yes")
    else:
        print("No")

It's true that the data is not corresponding to the input format, but there must be something else with the PyPy3 interpreter.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en7 Английский -14 2019-10-29 19:34:23 169
en6 Английский -14 2019-10-29 15:23:52 30 (published)
en5 Английский -14 2019-10-29 15:19:25 6 Tiny change: ' I realize there may' -> ' I realized that there may'
en4 Английский -14 2019-10-29 15:18:37 7 Tiny change: 'view other's submission so I past' -> 'view others' submissions so I past'
en3 Английский -14 2019-10-29 15:17:36 72
en2 Английский -14 2019-10-29 15:12:38 284
en1 Английский -14 2019-10-29 15:05:44 1868 Initial revision (saved to drafts)