Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. def test():
  2. MassR = [True] * 5000
  3. for i in range(2,5000):
  4. if MassR[i] == True:
  5. for j in range(i*i,5000,i):
  6. MassR[j] = False
  7. MassProst = []
  8. for i in range(2,5000):
  9. if len(MassProst) > 300:
  10. break
  11. else:
  12. if MassR[i] == True:
  13. MassProst.append(i)
  14. rep = True
  15. n = int(input())
  16. k = int(input())
  17. a = [0 for i in range(k)]
  18. ans = -1
  19. for i in range(k):
  20. a[i] = int(input())
  21. if(a[i] == 1):
  22. print("2")
  23. return 0
  24. for i in range(0,len(MassProst)):
  25. rep = False
  26. for j in range(k):
  27. if MassProst[j] == a[j]:
  28. rep = True
  29. if rep == False:
  30. ans = MassProst[i] * MassProst[i]
  31. break
  32. if ans <= n:
  33. print(ans)
  34. else:
  35. print("-1")
  36. test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement