We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1c8ef4 commit 617c0cbCopy full SHA for 617c0cb
βπ G3/15711.py
@@ -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
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
27
28
+ print("NO")
0 commit comments