Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int t;
- scanf("%d", &t);
- while(t--)
- {
- long long int n;
- scanf("%lld", &n);
- int cnt2 = 0, cnt3 = 0;
- while(n % 2 == 0)
- {
- cnt2++;
- n /= 2;
- }
- while(n % 3 == 0)
- {
- cnt3++;
- n /= 3;
- }
- if(n == 1 && cnt2 <= cnt3) printf("%d\n", 2*cnt3 - cnt2);
- else printf("-1\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment