Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int int64_t
- using namespace std;
- const int INF = 1e9 + 7;
- const int N = 1e5 + 10;
- int32_t main(){
- int a, b;
- cin >> a >> b;
- int ans = 0;
- if(b % a != 0){
- cout << -1;
- return 0;
- }
- int cur = b / a;
- while(cur % 2 == 0){
- cur /= 2;
- ans ++;
- }
- while(cur % 3 == 0){
- cur/= 3;
- ans ++;
- }
- if(cur == 1)
- cout << ans;
- else
- cout << -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement