Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- long long m;
- long long n;
- cin >> m >> n;
- long long dif = n / m;
- int ctr = 0;
- if (n == m) {
- cout << 0;
- return 0;
- }
- if (n % m != 0L || (n % 2 != 0 && n % 3 != 0)) {
- cout << -1;
- return 0;
- }
- while (dif % 2 == 0) dif /= 2, ctr++;
- while (dif % 3 == 0) dif /= 3, ctr++;
- cout << (dif == 1 ? dif : -1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement