Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int test;
- long long n, count;
- cin >> test;
- while (test--) {
- count = 0;
- cin >> n;
- if (n == 1) {
- cout << 0 << endl;
- continue;
- }
- while (n % 3 == 0) {
- if (n == 1) {
- break;
- }
- if (n % 6 == 0) {
- n /= 6;
- count++;
- } else {
- n *= 2;
- count++;
- }
- }
- if (n == 1) {
- cout << count << endl;
- } else {
- cout << -1 << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement