题解 | #skew数#
skew数
https://www.nowcoder.com/practice/5928127cc6604129923346e955e75984
#include <stdio.h> #include<math.h> // 计算字符串长度: int Length(char a[]) { int n = 0; for (int i = 0; a[i] != '\0'; i++) { n++; } return n; } int main() { char a[30] = ""; while ((scanf("%s", a)) != EOF) { int len = Length(a); int sum = 0; int i = 0; while (len--) { sum += ((a[i++] - '0') * (pow(2, len + 1) - 1)); } printf("%d\n", sum); } return 0; }