#include<stdio.h> #include<string.h> #include<math.h> int main() { char skem[100]; int k = 0; long sum = 0; //freopen("in.txt","r",stdin); while(gets(skem)) { int n = strlen(skem); int num = skem[0]-'0'; if(n==1 && num == 0) break; for(int i=0;i<n;i++) { k=n-i; sum += ((skem[i]-'0')*((long)pow(2,k)-1)); } printf("%ld\n",sum); sum = 0; } return 0; }
No comments:
Post a Comment