PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000213. Phân tích thành đúng k thừa số (k-Factorization)
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ành đúng k thừa số (k-Factorization)
Phân tích thành đúng k thừa số (k-Factorization)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , find exactly integers , each strictly greater than , such that their product equals . The factors need not be distinct. Print -1 if impossible; otherwise print any valid factorization.
Input
One line contains and .
Output
Print -1 if impossible; otherwise print space-separated integers.
Subtasks
-
Subtask 1 (20 points): ; .
-
Subtask 2 (30 points): ; .
-
Subtask 3 (50 points): ; .
Examples
Example 1
Input
100000 2
Output
2 50000
Explanation
2 and 50000 are greater than one and their product is 100000.
Example 2
Input
100000 20
Output
-1
Explanation
The prime-factor multiplicity of 100000 is only 10, so 20 factors are impossible.
Example 3
Input
1024 5
Output
2 2 2 2 64
Explanation
There are five factors 2,2,2,2,64; their product is 1024.