CF1176A.Divide it!
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an integer n .
You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times:
- Replace n with 2n if n is divisible by 2 ;
- Replace n with 32n if n is divisible by 3 ;
- Replace n with 54n if n is divisible by 5 .
For example, you can replace 30 with 15 using the first operation, with 20 using the second operation or with 24 using the third operation.
Your task is to find the minimum number of moves required to obtain 1 from n or say that it is impossible to do it.
You have to answer q independent queries.
输入格式
The first line of the input contains one integer q ( 1≤q≤1000 ) — the number of queries.
The next q lines contain the queries. For each query you are given the integer number n ( 1≤n≤1018 ).
输出格式
Print the answer for each query on a new line. If it is impossible to obtain 1 from n , print -1. Otherwise, print the minimum number of moves required to do it.
输入输出样例
输入#1
7 1 10 25 30 14 27 1000000000000000000
输出#1
0 4 6 6 -1 6 72