#SP0000032. Phân tích các số nguyên lớn (Factoring Large Numbers)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phân tích các số nguyên lớn (Factoring Large Numbers)
Factoring Large Numbers
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Factoring large integers into primes is an important operation in cryptography.
Given a positive integer , find all prime factors of and print them in nondecreasing order. If a prime occurs with multiplicity greater than one, print it once for each occurrence. Do not print the factor .
For example, has the four prime factors . If , there are no prime factors to print.
Input
One line containing a positive integer that fits in a signed 64-bit integer.
Output
Print each prime factor on a separate line in nondecreasing order; each such line begins with exactly four spaces before the factor. Print one blank line after the last factor. If , print only a blank line.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
90
Output
2
3
3
5
Explanation: For , divide by to get ; divide twice by , obtaining and then . The remaining is prime. Thus the ordered factors are , each indented by four spaces, followed by a blank line.
Example 2
Input
1234567891
Output
1234567891
Explanation: The number is prime, so its factorization consists only of itself; print it with four leading spaces and then a blank line.