fork(47) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t; cin.tie(nullptr)->sync_with_stdio(false), cin >> t;
  6. while (t--) {
  7. string S;
  8. cin >> S;
  9. int N = S.size();
  10. __int128 X = 0;
  11. for (int i = 0; i < N; ++i)
  12. if (X <<= 1, S[i] == '1')
  13. X |= 1;
  14. string ans;
  15. if (X == 0)
  16. ans = "0";
  17. else {
  18. while (X > 0)
  19. ans += char('0'+X%6), X /= 6;
  20. reverse(ans.begin(),ans.end()); }
  21. cout << ans << '\n'; }
  22. return 0; }
  23.  
Success #stdin #stdout 0s 5588KB
stdin
4
111
1000
1011101011101
11101110110101011101
stdout
11
12
43405
32545005