문제풀이/SW Expert Academy

[SWEA][D2] 1945. 간단한 소인수분해 (파이썬/Python)

얄루몬 2021. 10. 8. 13:50

t = int(input())
for tc in range(1,t+1):
    n = int(input())
    a=b=c=d=e=0
    while n % 2 == 0:
        a += 1
        n //= 2
    while n % 3 == 0:
        b += 1
        n //= 3
    while n % 5 == 0:
        c += 1
        n //= 5
    while n % 7 == 0:
        d += 1
        n //= 7
    while n % 11 == 0:
        e += 1
        n //= 11
    print(f"#{tc} {a} {b} {c} {d} {e}")