Skip to content

Commit 7e0d027

Browse files
committed
Added 1374B - Multiply by 2, divide by 6.cpp
1 parent 7dec50d commit 7e0d027

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Diff for: 1374B - Multiply by 2, divide by 6.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
// Code Written By: Vikash Patel
5+
6+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
7+
8+
int main()
9+
{
10+
int t;
11+
cin>>t;
12+
while(t--)
13+
{
14+
int n;
15+
cin>>n;
16+
int c = 0;
17+
while(n!=1)
18+
{
19+
if(n%6==0)
20+
{
21+
n /= 6;
22+
c++;
23+
}
24+
else if(n%3==0)
25+
{
26+
n *= 2;
27+
c++;
28+
}
29+
else
30+
{
31+
c = -1;
32+
break;
33+
}
34+
}
35+
cout<<c<<endl;
36+
}
37+
}

0 commit comments

Comments
 (0)