haju__log

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

SWEA

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

haju 2023. 5. 4. 22:06

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5Pl0Q6ANQDFAUq&categoryId=AV5Pl0Q6ANQDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=2&pageSize=10&pageIndex=2 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

T=int(input())

for test_case in range(1,T+1):
    n2=0
    n3=0
    n5=0
    n7=0
    n11=0
    n=int(input())
    while n%2==0:
        n2+=1
        n//=2
    while n%3==0:
        n3+=1
        n//=3
    while n%5==0:
        n5+=1
        n//=5
    while n%7==0:
        n7+=1
        n//=7
    while n%11==0:
        n11+=1
        n//=11

    print("#%d %d %d %d %d %d" %(test_case,n2,n3,n5,n7,n11))