#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
本文介绍了一个简单的算法题目,通过C++实现,展示了如何计算特定字符串的数学表达式。该算法利用了字符串操作和数学运算的基础知识。
1132

被折叠的 条评论
为什么被折叠?



