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.