PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000215. Phép nhân và căn bậc hai (Math)
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ép nhân và căn bậc hai (Math)
Phép nhân và căn bậc hai (Math)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Starting with positive integer , you may: (1) replace by for any positive integer ; or (2) replace by its integer square root, only when the square root is an integer. Find the smallest attainable value, and the fewest operations necessary to reach it.
Input
One line contains .
Output
Print the minimum reachable value and the minimum number of operations required.
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Example 1
Input
20
Output
10 2
Explanation
Multiply 20 by 5 to reach 100, then take the integer square root to reach 10.
Example 2
Input
5184
Output
6 4
Explanation
5184 -> 72 -> 1296 -> 36 -> 6 uses four operations.
Example 3
Input
1
Output
1 0
Explanation
The number 1 already has its minimum value.