poj 1565
题目:http://poj.org/problem?id=1565
View Code
1 typedef long long ll; 2 char str[40]; 3 ll mypow(int len) 4 { 5 int i; 6 ll temp = 1; 7 for(i = 0; i < len; i++) 8 temp *= 2; 9 return temp; 10 } 11 int main() 12 { 13 int i,len; 14 while(~scanf("%s",str)) 15 { 16 if(str[0] == '0') break; 17 len = strlen(str); 18 ll sum = 0; 19 for(i = 0; i < len; i++) 20 { 21 int k = str[i] - '0'; 22 if(!k) continue; 23 sum += (k * (mypow(len - i) - 1)); 24 } 25 cout<<sum<<endl; 26 } 27 return 0; 28 }