Back to list of problems
Skew Binary
575.c
/* Skew Binary */ #include <stdio.h> int main(void) { char buf[1024]; int len; int i; while(1) { int num=0; scanf("%s", buf); len = strlen(buf); for(i=0; i<len; i++) { num += (buf[len-i-1]-'0')*((1<<(i+1))-1); } if (num==0) { break; } else { printf("%d\n", num); } } exit(0); }