๋ฐฑ์ค€๐Ÿ“Œ18 (๊ตฌํ˜„) - ์„คํƒ•๋ฐฐ๋‹ฌ # 2839๋ฒˆ

imsยท2021๋…„ 7์›” 15์ผ
0

๋ฐฑ์ค€ ๋ฌธ์ œํ’€์ด

๋ชฉ๋ก ๋ณด๊ธฐ
17/17

๐Ÿ“Œ ๋ฌธ์ œ

n์ด ์ฃผ์–ด์งˆ ๋•Œ, 5์™€ 3์„ ๋นผ์„œ 0์ด ๋  ์ˆ˜ ์žˆ๋Š” ์ง€ ํ™•์ธํ•œ๋‹ค.
5๋ฅผ ๋จผ์ € ๋บ„ ์ˆ˜ ์žˆ์„ ๋•Œ๋Š” 5๋ฅผ ๋บ€๋‹ค. 5์™€ 3์„ ๋บ€ ํšŸ์ˆ˜๋ฅผ ๊ตฌํ•˜๋ผ.

๐Ÿ“Œ ํ’€์ด๊ณผ์ •

๋‚˜๋Š” 5์„ ๋จผ์ € ๋นผ๊ณ , 3์ด ๋‚จ๋Š” case๋ฅผ ์ƒ๊ฐํ•ด์„œ ๊ตฌํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ์ƒ๋‹นํžˆ ๋ณต์žกํ–ˆ๋‹ค.

๋ฐ˜๋Œ€๋กœ, 3์ด ๋จผ์ € ๋น ์ ธ์„œ 5์˜ ๋ฐฐ์ˆ˜๊ฐ€ ๋  ๋•Œ๊นŒ์ง€ ๋Œ๊ณ , 5์˜ ๋ฐฐ์ˆ˜๊ฐ€ ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ๋˜์ง€ ์•Š๋Š” ๊ฒƒ์ด๋ผ ์ƒ๊ฐํ•˜๋ฉด ์‰ฝ๋‹ค.

์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ์ฐธ์กฐํ–ˆ๋‹ค.

https://ooyoung.tistory.com/81

๐Ÿ“Œ ์ฝ”๋“œ

import sys

n = int(input())

count = 0

while n>=0:
    if n%5==0:
        count += n//5
        print(count)
        sys.exit(0)
    n-=3
    count+=1

print(-1)
profile
ํ‹ฐ์Šคํ† ๋ฆฌ๋กœ ์ด์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค! https://imsfromseoul.tistory.com/ + https://camel-man-ims.tistory.com/

0๊ฐœ์˜ ๋Œ“๊ธ€