문제 풀이/SWEA
1945. 간단한 소인수분해
zhelddustmq
2024. 7. 15. 16:10
문제: 무단 배포 금지로 인해 사이트 주소로 남깁니다.
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5Pl0Q6ANQDFAUq
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
정답 코드:
T = int(input())
for test_case in range(1, T + 1):
N = int(input())
two = 0
three = 0
five = 0
seven = 0
eleven = 0
while N % 2 == 0:
N //= 2
two += 1
while N % 3 == 0:
N //= 3
three += 1
while N % 5 == 0:
N //= 5
five += 1
while N % 7 == 0:
N //= 7
seven += 1
while N % 11 == 0:
N //= 11
eleven += 1
print(f"#{test_case} {two} {three} {five} {seven} {eleven}")