Today when I am trying to solve [acmsguru-113](https://codeforces.net/problemsets/acmsguru/problem/99999/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 realized that there may be problems in input format, so I wriote 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' was an accepted!↵
↵
Here are the python code with tokenizer, and submissions with this code : (It's not allow to view others' submissions so I paste here)↵
↵
63721667 Oct/29/2019 19:32UTC+8 Lily 113 — Nearly prime numbers Python 3 Accepted 186 ms 0 KB↵
↵
63721403 Oct/29/2019 19:28UTC+8 Lily 113 — Nearly prime numbers PyPy 3 Wrong answer on test 1 124 ms 0 KB ↵
↵
~~~~~python↵
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 found it true that the data is not corresponding to the input format by asserting, but there must be something else with the PyPy3 interpreter.↵
↵
Could anybody help me find the reason of it? Thanks a lot. QAQ↵
↵
Then I realized that there may be problems in input format, so I wr
↵
After one hour of struggling in finding bugs and differences, I found nothing but submitted it with Python3 — and it
↵
Here are the python code with tokenizer, and submissions with this code : (It's not allow to view others' submissions so I paste here)↵
↵
63721667 Oct/29/2019 19:32UTC+8 Lily 113 — Nearly prime numbers Python 3 Accepted 186 ms 0 KB↵
↵
63721403 Oct/29/2019 19:28UTC+8 Lily 113 — Nearly prime numbers PyPy 3 Wrong answer on test 1 124 ms 0 KB ↵
↵
~~~~~python↵
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")↵
~~~~~↵
↵
I
↵
Could anybody help me find the reason of it? Thanks a lot. QAQ↵