-
Notifications
You must be signed in to change notification settings - Fork 65
/
1176 A. Divide it!.cpp
48 lines (47 loc) · 1.04 KB
/
1176 A. Divide it!.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
47
48
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
using namespace std;
int main()
{
fastread();
int t;
ull n;
cin>>t;
while(t--)
{
cin>>n;
if(n == 1){
cout<<0<<endl;
continue;
}
int ans = 0;
while(n > 1){
if(n % 2 == 0){
n/=2;
ans++;
}
else if(n % 3 == 0){
n = (2*n)/3;
ans++;
}
else if(n % 5 == 0){
n = (4*n)/5;
ans++;
}
else if( (n % 2 != 0 && n % 3 != 0) && (n % 5 != 0) ){
if(n != 1){
cout<<"-1\n";
break;
}
}
if(n == 1){
cout<<ans<<endl;
break;
}
}
}
return 0;
}