题解 | #skew数#
skew数
https://www.nowcoder.com/practice/5928127cc6604129923346e955e75984
#include <iostream> #include <cmath> using namespace std; int main() { // int a, b; string str; // while (cin) { // 注意 while 处理多个 case // cout << a + b << endl; // } while (getline(cin, str)) { int skew = 0; for (int i = 0; i < str.size(); i++) { int n = str.size() - i; int k = 2; for (int j = 1; j < n; j++) k *= 2; skew += (str[i] - '0') * (k - 1); } cout << skew << endl; } } // 64 位输出请用 printf("%lld")