MapleStory Finger Point

๐Ÿƒ‍โ™‚๏ธBaekjoon/Python

#2581 - python ์†Œ์ˆ˜

HYEJU01 2024. 5. 18. 22:03
์ฒด๊ฐ Level : โ˜… โ˜† โ˜†
Review:  ์†Œ์ˆ˜ ๊ตฌํ•˜๋Š” ๋ฒ•, ์นด์šดํŒ… ํ•˜๋Š” ๋ฐฉ๋ฒ•, ์ตœ๋Œ€๊ฐ’ ๊ตฌํ•˜๋Š” ๋ฐฉ๋ฒ• ์ด ์„ž์—ฌ์žˆ๋‹ค!
์กฐ๊ฑด ์ฃผ๋Š”๊ฒŒ ์‚ด์ง ๊นŒ๋‹ค๋กœ์šธ ์ˆ˜๋„ ์žˆ๊ฒ ๋‹ค!!

 

๐Ÿ’ก M์ด์ƒ N์ดํ•˜์˜ ์ž์—ฐ์ˆ˜ ์ค‘ ์†Œ์ˆ˜์ธ ๊ฒƒ์„ ๋ชจ๋‘ ์ฐพ์•„ ์ฒซ์งธ ์ค„์— ๊ทธ ํ•ฉ์„, ๋‘˜์งธ ์ค„์— ๊ทธ ์ค‘ ์ตœ์†Ÿ๊ฐ’์„ ์ถœ๋ ฅ

 

๐Ÿ’ฌ import sys / print(sys.maxsize)  :: ํŒŒ์ด์ฌ ์ •์ˆ˜ ์ตœ๋Œ€๊ฐ’ (๊ฐ€์žฅ ํฐ ์–‘์ˆ˜๊ฐ’)

import sys

M = int(input())
N = int(input())

cnt = 0
sum = 0
min = sys.maxsize

for i in range(M,N+1):
    cnt = 0
    for j in range(1,i):
        if (i%j ==0):
            cnt +=1
    if (cnt == 1):
        sum += i
        if (i < min):
            min = i

if (sum == 0):
    print (-1)
else:
    print (sum)
    print (min)