-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2323.py
More file actions
39 lines (34 loc) · 929 Bytes
/
2323.py
File metadata and controls
39 lines (34 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from ast import Return
import sys
read=sys.stdin.readline
n=int(read())
result=[]
a=[False,False]+[True]*9999
for i in range(2,101):
if a[i]:
for i in range(2*i,10001,i):
a[i]=False
prime=[i for i in range(2,10001) if a[i]==True]
def binary(num):
count=num//2+1
first_indx=0
last_indx=len(prime)-1
while True:
if first_indx+1==last_indx:
return last_indx
break
if count<prime[(first_indx+last_indx)//2]:
last_indx=(first_indx+last_indx)//2
elif count>prime[(first_indx+last_indx)//2]:
first_indx=(first_indx+last_indx)//2
elif count==prime[(first_indx+last_indx)//2]:
return (first_indx+last_indx)//2
break
print(prime)
for i in range(n):
x=int(read())
for j in prime[0:binary(x)+1:-1]:
print(j)
if x-j in prime:
print(x-j,j)
break