UVA 575-Skew Binary
题目大意:按公式计算
解题思路:直接套公式
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main() {
char a[1000];
while(gets(a) && a[0] != '0') {
int n = strlen(a);
long long int s = 0;
for(int i = 0; i < n; i++) {
s = s + (a[i] - '0') * (pow(2, n-i) - 1);
}
printf("%lld\n", s);
}
return 0;
}