[SWEA D2] 1945. 간단한 소인수분해

shin·2022년 11월 8일
0

CodingTest 문제 풀이

목록 보기
23/79

문제

  • N = 2^a x 3^b x 5^c x 7^d x 11^e
  • N이 주어질 때 a, b, c, d, e 를 출력하라

풀이

T = int(input())
for t in range(1, T + 1):
    n = int(input())
    num = [11, 7, 5, 3, 2]
    count = [0, 0, 0, 0, 0]
    for i in range(5):
        while True:
            if n % num[i] == 0:
                n = n / num[i]
                count[4 - i] += 1
            else:
                break
    print(f"#{t} {count[0]} {count[1]} {count[2]} {count[3]} {count[4]}")
profile
Backend development

0개의 댓글