题解 | #skew数#
skew数
http://www.nowcoder.com/practice/5928127cc6604129923346e955e75984
#include <stdio.h> #include <string.h> #include <math.h> #define MAX 32 int main(void) { char s[MAX]; while (scanf("%s", s) != EOF) { long answr = 0; int n = strlen(s); for (int i = 0; i < n; i++) { // printf("%d ", s[i] - '0'); answr += (s[i] - '0') * (pow(2, n - i) - 1); } // printf("\n"); printf("%ld\n", answr); } return 0; }