Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int int64_t
  3. using namespace std;
  4.  
  5. const int INF = 1e9 + 7;
  6. const int N = 1e5 + 10;
  7.  
  8. int32_t main(){
  9. int a, b;
  10. cin >> a >> b;
  11. int ans = 0;
  12. if(b % a != 0){
  13. cout << -1;
  14. return 0;
  15. }
  16. int cur = b / a;
  17. while(cur % 2 == 0){
  18. cur /= 2;
  19. ans ++;
  20. }
  21. while(cur % 3 == 0){
  22. cur/= 3;
  23. ans ++;
  24. }
  25. if(cur == 1)
  26. cout << ans;
  27. else
  28. cout << -1;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement