๋์ ํ์ด
T = int(input())
# ์ฌ๋ฌ๊ฐ์ ํ
์คํธ ์ผ์ด์ค๊ฐ ์ฃผ์ด์ง๋ฏ๋ก, ๊ฐ๊ฐ์ ์ฒ๋ฆฌํฉ๋๋ค.
for t in range(1, T + 1):
n = int(input())
arr = [2,3,5,7,11]
print("#"+str(t) , end=" ")
for i in arr:
cnt = 0
while n%i ==0:
cnt += 1
n = n//i
print(cnt , end=" ")
print()
๋ฐฐ์ด๋ก ๋ง๋ค๊ณ ๋ฐ๋ณตํ๊ฒ ๋ง๋ค์๋ค.
๋ฐฐ์ด ๋ฐ๋ณต ์ํํ ๋๋ง๋ค ์นด์ดํฐ ๋ณ์๋ฅผ ์ด๊ธฐํํ๊ณ ๊ฐ์ ๊ตฌํ๊ณ ์ถ๋ ฅ
๋ค๋ฅธํ์ด ์ฐพ์๋ดค๋๋ฐ
๋ฐฐ์ด for ๋ฌธ์ while ์กฐ๊ฑด๋ฃ์ด์ ๊ตฌํ๊ธฐ
๋๋ถ๋ถ ์ด๋ ๊ฒ ํธ๋๋ฏ?
'Algorithm > SWEA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SWEA - D2] 1989. ์ด์ฌ์์ ํ๋ฌธ ๊ฒ์ฌ (0) | 2023.04.13 |
---|---|
[SWEA - D2] 1284. ์๋ ์๊ธ ๊ฒฝ์ (1) | 2023.04.12 |
[SWEA - D2] 1288. ์๋ก์ด ๋ถ๋ฉด์ฆ ์น๋ฃ๋ฒ (0) | 2023.04.12 |
[SWEA - D2] 1986. ์ง๊ทธ์ฌ๊ทธ ์ซ์ (0) | 2023.04.12 |
[SWEA] D1 ๋ฌธ์ ํ์ด (0) | 2023.04.11 |