Untitled
unknown
c_cpp
4 years ago
651 B
4
Indexable
#include <bits/stdc++.h> #define faster() \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); typedef unsigned long long int lli; using namespace std; lli mu(int n, int k) { lli ans = 1; for (int i = 1; i <= k; i++) { ans *= n; } return ans; } int main() { faster(); int test; cin >> test; while (test--) { string str; cin >> str; //base 2 to base 10 lli ans = 0; for (int i = 0; i < str.size(); i++) { ans += (str[i] - '0') * mu(2, str.size() - 1 - i); } cout << ans << endl; } return 0; }
Editor is loading...