Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define dbgA2(A, n, m) \
- { \
- cout << "-->" << #A << "=\n"; \
- for (int i = 0; i < n; i++) { \
- for (int j = 0; j < n; j++) { \
- cout << A[i][j] << " "; \
- } \
- cout << "\n"; \
- } \
- cout << "\n"; \
- }
- #define dbgA(A, n) \
- { \
- cout << "-->" << #A << "=("; \
- for (int i = 0; i < n; i++) \
- cout << A[i] << " "; \
- cout << ")\n"; \
- }
- #define dbg(args...) \
- { \
- string sss(#args); \
- sss += ','; \
- cout << "-->"; \
- debugger::call(sss.begin(), sss.end(), args); \
- cout << "\n"; \
- }
- using namespace std;
- struct debugger {
- typedef string::iterator si;
- static void call(si it, si ed) {}
- template<typename T, typename... aT>
- static void call(si it, si ed, T a, aT... rest) {
- string b;
- for (; *it != ','; ++it)
- if (*it != ' ')
- b += *it;
- cout << b << "=" << a << " ";
- call(++it, ed, rest...);
- }
- };
- /***********************************************************************/
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t, a;
- cin >> t;
- // long long int m=1000000000;
- while (t--) {
- int n, cnt = 0, flag = 0;
- cin >> n;
- while (n % 3 == 0) {
- if (n % 6 != 0) {
- n = n * 2;
- cnt++;
- if (n % 6 == 0) {
- n = n / 6;
- cnt++;
- flag = 1;
- }
- }
- if (n % 6 == 0) {
- n = n / 6;
- cnt++;
- flag = 1;
- }
- if (flag == 0)
- break;
- }
- if (n == 1)
- cout << cnt << endl;
- else
- cout << "-1" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement