-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1176A.cpp
46 lines (40 loc) · 798 Bytes
/
1176A.cpp
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
/*
* Author: Rushi Vachhani
* Platform: Codeforces
* Problem_ID: 1176A
* Language: C++
*/
#include<bits/stdc++.h>
using namespace std;
void solve() {
long long n;
cin >> n;
if(n==1) { cout<<0<<"\n"; return; }
else{
long long count2=0, count3=0, count5=0;
while(n%2==0) {
n = n/2;
count2++;
}
while(n%3==0) {
n = n/3;
count3++;
}
while(n%5==0) {
n = n/5;
count5++;
}
if(n!=1) { cout<<-1<<"\n"; return; }
else { cout<<count2 + (2*count3) + (3*count5)<<"\n"; return; }
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--) {
solve();
}
return 0;
}