Skip to content

Commit 617c0cb

Browse files
committed
πŸ‘‘ G3-15711
1 parent e1c8ef4 commit 617c0cb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

β€ŽπŸ‘‘ G3/15711.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
t = int(input())
2+
_max = int((4*10**12)**0.5)+1
3+
isPrime = [1]*(_max+1)
4+
5+
for i in range(2, int(_max**0.5)+1):
6+
if isPrime[i]:
7+
j = 2
8+
while i*j <= _max:
9+
isPrime[i*j] = 0
10+
j += 1
11+
12+
def checkPrime(n):
13+
if n < 2:
14+
return False
15+
for i in range(2, int(n**0.5)+1):
16+
if isPrime[i] and n % i == 0:
17+
return False
18+
return True
19+
20+
for _ in range(t):
21+
a, b = map(int, input().split())
22+
if a+b != 2 and (a+b) % 2 == 0:
23+
print("YES")
24+
else:
25+
if checkPrime(a+b-2):
26+
print("YES")
27+
else:
28+
print("NO")

0 commit comments

Comments
Β (0)