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