forked from buglinjo/codeforces
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1374B.cpp
More file actions
49 lines (49 loc) · 985 Bytes
/
1374B.cpp
File metadata and controls
49 lines (49 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
int min(int a, int b) {
if (a < b)
return a;
else
return b;
}
bool compare(int a, int b) {
return a > b;
}
int32_t main() {
fio;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
bool curr = true;
int count = 0;
while (n > 1) {
if (n % 6 == 0) {
n = n / 6;
count++;
}
else {
if (n % 3 == 0) {
n = n * 2;
count++;
}
else {
curr = false;
break;
}
}
}
if (curr) {
cout << count << endl;
}
else {
cout << "-1" << endl;
}
}
return 0;
}