Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def test():
- MassR = [True] * 5000
- for i in range(2,5000):
- if MassR[i] == True:
- for j in range(i*i,5000,i):
- MassR[j] = False
- MassProst = []
- for i in range(2,5000):
- if len(MassProst) > 300:
- break
- else:
- if MassR[i] == True:
- MassProst.append(i)
- rep = True
- n = int(input())
- k = int(input())
- a = [0 for i in range(k)]
- ans = -1
- for i in range(k):
- a[i] = int(input())
- if(a[i] == 1):
- print("2")
- return 0
- for i in range(0,len(MassProst)):
- rep = False
- for j in range(k):
- if MassProst[j] == a[j]:
- rep = True
- if rep == False:
- ans = MassProst[i] * MassProst[i]
- break
- if ans <= n:
- print(ans)
- else:
- print("-1")
- test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement