Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
- #define pi pair<int , int>
- #define mp make_pair
- #define f first
- #define s second
- int main()
- {
- fast();
- ll t;
- cin>>t;
- while(t--)
- {
- ll n;
- cin>>n;
- ll cnt=0;
- while(n>1)
- {
- if(n%6==0)
- {
- n/=6;
- cnt++;
- }
- else
- {
- n*=2;
- cnt++;
- if(n%6==0)continue;
- else break;
- }
- }
- if(n==1)cout<<cnt<<endl;
- else cout<<-1<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement