#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
long long ans;
int len;
char s[100];
int main()
{
while(gets(s)&&s[0]!='0')
{
len = strlen(s);
ans = 0;
for(int i = 0;i < len;i++)
{
ans += (pow(2, len-i) - 1)*(s[i] - '0');
}
printf("%lld\n", ans);
}
return 0;
}
这个太水了,没什么说的,看懂题意即可
转载于:https://www.cnblogs.com/ACKOKO/articles/2045022.html