Codeforces 1374B. Multiply by 2, divide by 6 Solution
- Solution in C++:
- ///**********ALLAH IS ALMIGHTY************///
- ///AH Tonmoy
- ///Department of CSE,23rd batch
- ///Islamic University,Bangladesh
- #include<iostream>
- using namespace std;
- int main()
- {
- int n,c,t;
- cin>>t;
- while(t--)
- {
- c=0;
- cin>>n;
- while(n%6==0)
- {
- n=n/6;
- c++;
- }
- while(n%3==0)
- {
- n=n/3;
- c=c+2;
- }
- if(n==1)
- cout<<c<<endl;
- else
- cout<<"-1"<<endl;
- }
- }
No comments