PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000028. Phân tích thừa số có dấu (Prime Factors)
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ố có dấu (Prime Factors)
Prime Factors
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer other than , , or , output its prime factorization. Prime factors must appear in nondecreasing order, including repetitions.
If , start with the factor and then list the prime factors of . If , list only its prime factors.
Input
One line containing the integer .
Output
Print one line formatted as g = f1 x f2 x ... x fk; the multiplication symbol is lowercase x with one space on each side. For negative , the first factor is -1.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
-190
Output
-190 = -1 x 2 x 5 x 19
Explanation
Since and are prime, the signed factorization is .
Input
196
Output
196 = 2 x 2 x 7 x 7
Explanation
We have , printed in nondecreasing order.