-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path50.py
More file actions
40 lines (33 loc) · 749 Bytes
/
50.py
File metadata and controls
40 lines (33 loc) · 749 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
37
38
39
40
import time
def solve():
m=0
ans=0
for i in range(len(prime)):
s=prime[i]
con=1
for j in range(i+1,len(prime)):
s+=prime[j]
con+=1
if s>=prime[-1]:
break
if s in search.keys() and con>m:
m=con
ans=s
print("Answer",ans)
print("started")
st=time.time()
n=10**6+1
p=[True]*n
for i in range(2,n):
for j in range(i*2,n,i):
p[j]=False
prime=[]
search={}
print(time.time()-st,"sec part 1 prime")
for i in range(2,n):
if p[i]:
prime.append(i)
search[i]=1
print(time.time()-st,"sec part 2 prime")
solve()
print("done\n","Time:",time.time()-st)