Skip to content

Commit f625a11

Browse files
committed
learned math vid
1 parent 7be7b43 commit f625a11

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

B_Multiply_by_2_divide_by_6.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
////https://codeforces.com/contest/266/problem/A
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
typedef long long ll;
5+
const int mod = 1e9 + 7;
6+
const int N = 1e5 + 5;
7+
8+
void solve()
9+
{
10+
11+
int n; cin >> n;
12+
13+
int count = 0;
14+
while (n % 6 == 0)
15+
{
16+
n /= 6;
17+
count++;
18+
}
19+
20+
while (n % 3 == 0)
21+
{
22+
23+
n /= 3;
24+
count = count + 2;
25+
}
26+
if (n == 1)
27+
cout << count << endl;
28+
else
29+
cout << "-1" << endl;
30+
}
31+
32+
int main()
33+
{
34+
ios_base::sync_with_stdio(0);
35+
cin.tie(0);
36+
int t;
37+
cin >> t;
38+
while (t--)
39+
{
40+
solve();
41+
}
42+
}

0 commit comments

Comments
 (0)