PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000020. Phân tích thừa số nguyên tố có nhãn (Prime Factorization)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Phân tích thừa số nguyên tố có nhãn (Prime Factorization)
Prime Factorization
Source: Aizu Online Judge
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer , factor it into primes, retaining all repeated occurrences in non-decreasing order. The required formatting is specific: print the original integer first, followed by a colon and one space before the factor list.
Input
One line contains integer .
Output
Print n: with replaced by the input value, followed by one space and the prime factors separated by spaces.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
12
Output
12: 2 2 3
Explanation
Divide by to obtain , divide again by to obtain , and keep the final prime . With the 12: prefix, the result is 12: 2 2 3.
Input
126
Output
126: 2 3 3 7
Explanation
Since , list the sorted factors after the 126: prefix.