-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1374a.cpp
More file actions
47 lines (39 loc) · 781 Bytes
/
1374a.cpp
File metadata and controls
47 lines (39 loc) · 781 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
#include <bits/stdc++.h>
using namespace std;
bool checkParity(int a,int b){
if(a%2==0 && b%2 == 0 || a%2==1 && b%2 == 1){
return true;
}else{
return false;
}
}
int main() {
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
int ans = 0;
int count_2 = 0;
int count_3 = 0;
while(n%2 == 0){
count_2++;
n /= 2;
}
while(n%3 == 0){
count_3++;
n /=3;
}
if(n != 1){
ans = -1;
}else{
if(count_2 > count_3){
ans = -1;
}else{
ans = count_3 + (count_3-count_2);
}
}
cout << ans << "\n";
}
return 0;
}