Skip to content

Commit

Permalink
Merge pull request #30 from inthewalter/2581
Browse files Browse the repository at this point in the history
Solve #6 2581 소수
  • Loading branch information
Yongho Lee authored Apr 8, 2019
2 parents 670a4cd + 49a2401 commit 719bd2a
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions problems/2581/21400564.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 19-1
# 21400564 이용호
import time
import sys

class Solution :
def __init__(self):
self.primeList = [2]
pass

def makePrimeList(self, x):
for i in self.primeList :
if x % i == 0 :
return False
self.primeList.append(x)
return True

def test(self, M, N):
for i in range(2, N+1):
self.makePrimeList(i)
minValue = -1
for i in range(M, N+1):
if i in self.primeList:
minValue = i
break
if minValue == -1 :
print(-1)
return False

minValueIndex = self.primeList.index(minValue)
sumOfSolutions = sum([self.primeList[x] for x in range(minValueIndex, len(self.primeList))])

# print solution
print(sumOfSolutions)
print(self.primeList[minValueIndex])

if __name__ == "__main__":
input1 = int(sys.stdin.readline())
input2 = int(sys.stdin.readline())

solution = Solution()

# start_time = time.time()
solution.test(input1, input2)
# print("--- %s seconds ---" %(time.time() - start_time))

0 comments on commit 719bd2a

Please sign in to comment.