PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000032. Phân tích các số nguyên lớn (Factoring Large Numbers)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

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 NN, find all prime factors of NN 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 11.

For example, 90=2⋅3⋅3⋅590=2\cdot3\cdot3\cdot5 has the four prime factors 2,3,3,52,3,3,5. If N=1N=1, there are no prime factors to print.

Input

One line containing a positive integer NN 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 N=1N=1, print only a blank line.

Subtasks

  • Subtask 1 (20 points): 1≤N≤1061\le N\le10^6.
  • Subtask 2 (30 points): 1≤N≤10121\le N\le10^{12}.
  • Subtask 3 (50 points): 1≤N≤263−11\le N\le2^{63}-1.

Examples

Example 1

Input

90

Output

    2
    3
    3
    5

Explanation: For 9090, divide by 22 to get 4545; divide twice by 33, obtaining 1515 and then 55. The remaining 55 is prime. Thus the ordered factors are 2,3,3,52,3,3,5, each indented by four spaces, followed by a blank line.

Example 2

Input

1234567891

Output

    1234567891

Explanation: The number 12345678911234567891 is prime, so its factorization consists only of itself; print it with four leading spaces and then a blank line.