Advertisement
noshin98

uva 575

Jul 5th, 2016
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<string.h>
  4. int main()
  5. {
  6.     long long l,i,sum,b,num;
  7.     char s[100];
  8.     while(gets(s))
  9.     {
  10.         sum=0;
  11.         l=strlen(s);
  12.  
  13.         for(i=0;i<l;i++)
  14.         {
  15.             num=s[i]-'0';
  16.             b=num*(pow(2,l-i)-1);
  17.             sum=sum+b;
  18.         }
  19.         if(sum==0)
  20.             break;
  21.  
  22.         printf("%lld\n",sum);
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement