#include <iostream> #include <math.h> using namespace std; int main() { string str; while (cin>>str) { int sum = 0,i,j,len = str.length(); for(i=len-1,j=0;i>=0&&j<len;i--,j++){ sum += (str[i]-'0')*(pow(2, j+1)-1); } cout<<sum<<endl; } }
#include <iostream> #include <math.h> using namespace std; int main() { string str; while (cin>>str) { int sum = 0,i,j,len = str.length(); for(i=len-1,j=0;i>=0&&j<len;i--,j++){ sum += (str[i]-'0')*(pow(2, j+1)-1); } cout<<sum<<endl; } }