PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000203. Phân tích giai thừa thành thừa số nguyên tố (Prime Time)
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 giai thừa thành thừa số nguyên tố (Prime Time)
Prime Time
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer , its factorial has a unique prime factorization
where are all primes not exceeding , and is the exponent of in .
Print this factorization in increasing prime order. Use the literal character ^ for exponents and the string * between consecutive factors.
Input
The only line contains the integer .
Output
Print one line of the form p1^e1 * p2^e2 * ... * pk^ek, with no leading or trailing *.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
6
Output
2^4 * 3^2 * 5^1
Explanation
We have . The primes are with exponents , respectively. Therefore the required output is 2^4 * 3^2 * 5^1.