#SP0000272. Phân tích thừa số nguyên tố (15 chữ số) (Integer Factorization (15 digits))
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phân tích thừa số nguyên tố (15 chữ số) (Integer Factorization (15 digits))
Integer Factorization (15 digits)
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given a positive integer , factor it into primes. For each distinct prime , let be its multiplicity in the factorization. Print every in ascending order of , including the exponent when it occurs.
Input
One line contains the positive integer .
Output
Print one line of pairs p^e, one for each distinct prime factor with its exponent . Sort the pairs by increasing , separating adjacent pairs by one space. Always print the exponent, including ^1.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
3111989
Output
317^1 9817^1
Explanation
Starting from , divide successively by prime factors: ; . Sort distinct prime factors in increasing order, writing each exponent including , and separate the pairs by spaces. The output line is 317^1 9817^1.
Example 2
Input
13091989
Output
17^2 89^1 509^1
Explanation
Starting from , divide successively by prime factors: ; ; ; . Sort distinct prime factors in increasing order, writing each exponent including , and separate the pairs by spaces. The output line is 17^2 89^1 509^1.
Example 3
Input
77145199750673
Output
328439^1 234884407^1
Explanation
Starting from , divide successively by prime factors: ; . Sort distinct prime factors in increasing order, writing each exponent including , and separate the pairs by spaces. The output line is 328439^1 234884407^1.