题解 | #skew数#
skew数
https://www.nowcoder.com/practice/5928127cc6604129923346e955e75984
#include<cstdio> #include<string> #include<math.h> using namespace std; int main(){ char arr[100]; while( scanf("%s",arr) != EOF){ string buf = arr; int totalsum = 0; for (unsigned i = 0; i < buf.size(); ++i) { int num = buf[i] - '0'; totalsum = totalsum + num * (pow(2,buf.size()-i) - 1); } printf("%d\n",totalsum); } }