4401 - 내림차순 소인수 분해

Time Limit: 1s Memory Limit: 128MB

Submissions: 966 Solved: 436
Description

사용자로부터 양의 정수 n을 입력받아, 내림차순으로 n의 소인수 분해 결과를 출력하는 프로그램을 작성하시오. 예를 들어 양의 정수 120이 주어졌을때 5 3 2 2 2로 소인수 분해 결과가 출력되어야 합니다. 

(Displaying the prime factors) Write a program that prompts the user to enter a positive integer and displays all its smallest factors in decreasing order. For example, if the integer is 120, the smallest factors are displayed as 5, 3, 2, 2, 2. Use the StackOfIntegers class to store the factors (e.g., 2, 2, 2, 3, 5) and retrieve and display them in reverse order.

Input

* Line 1 : 테스트케이스 T (1~1,000)

* Line 2 ~ T+1 : 소인수 분해할 양의 정수 n (1~1,000,000)

Output

* Line 1 ~ T : 공백으로 구분된 내림차순 소인수 분해 결과

Sample Input
3
3
10
120
Sample Output
3
5 2
5 3 2 2 2
Hint

StackOfInteger 클래스를 사용하세요.

Source

JAVA2015 PE10.5