-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1141.cpp
42 lines (35 loc) · 855 Bytes
/
1141.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
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,m,num;
int test;
cin >> n >> m;
int count = 0;
num = n;
if(n==m)
cout << 0 << endl;
else if( m%n!=0 || m<n)
cout << -1 << endl;
else if(m%n==0)
{
while(1)
{
num = num * 2;
if(num%n==0)
{
num = num * 2;
count++;
if(num==m)
cout << count << endl;
}
else
{
num = num * 3;
count++;
if(num==m)
cout << count << endl;
}
}
}
}