Saleh127

cf 1374B

Jun 28th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. test
  10. {
  11. ll a,c=0,d=0,e,f,i,j,k,l;
  12. cin>>a;
  13. while(1)
  14. {
  15. if(a==1) break;
  16. else if(a%6==0)
  17. {
  18. a/=6;
  19. c++;
  20. }
  21. else if((a*2)%6==0)
  22. {
  23. a*=2;
  24. a/=6;
  25. c+=2;
  26. }
  27. else
  28. {
  29. d=1;
  30. break;
  31. }
  32. }
  33. if(d==1) cout<<-1<<endl;
  34. else cout<<c<<endl;
  35. }
  36. return 0;
  37. }
Add Comment
Please, Sign In to add comment