Reduce a Number to One
You are given an integer n. In one move, you can either:
Multiply n by 2, or Divide n by 6 (only if it is divisible by 6 without a remainder).
Return the minimum number of moves needed to obtain 1 from n, or return -1 if it's impossible to do so.
Example 1
Input:
1
Output:
0
Example 2
Input:
2
Output:
-1
main.cpp
C++
AIã«è³ªåãã
AIã«è³ªåãã
äœã§ã質åããããææ¡ããã質åã®1ã€ã詊ããŠãã£ãããå§ããŠãã ãã