PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000013. Nhân 2 hoặc chia 6 (Multiply by 2, divide by 6)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nhân 2 hoặc chia 6 (Multiply by 2, divide by 6)
Multiply by 2, divide by 6
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Starting from a positive integer , you may either multiply the current value by , or divide it by when exactly divisible. Find the minimum number of operations to reach , or output -1 if impossible.
Input
One line containing .
Output
Print the minimum number of moves or -1.
Subtasks
- Subtask 1 (20 points):
- Subtask 2 (30 points):
- Subtask 3 (50 points):
Examples
Input
3
Output
2
Explanation
Multiply by to obtain , then divide by to reach in two operations.