#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
using namespace std;
int main()
{
int cse=0,cnt=0,flg=0;
long int n,i,sum,num,b;
char s[100];
while(gets(s))
{
sum=0;
n=strlen(s);
for(i=0; i<n; i++)
{
num=s[i]-'0';
b=num*(pow(2,n-i)-1);
sum=sum+b;
}
if(sum==0) break;
printf("%ld\n",sum);
}
return 0;
}
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
using namespace std;
int main()
{
int cse=0,cnt=0,flg=0;
long int n,i,sum,num,b;
char s[100];
while(gets(s))
{
sum=0;
n=strlen(s);
for(i=0; i<n; i++)
{
num=s[i]-'0';
b=num*(pow(2,n-i)-1);
sum=sum+b;
}
if(sum==0) break;
printf("%ld\n",sum);
}
return 0;
}
No comments:
Post a Comment