水。。。
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
char s[100];
int res;
int main()
{
while(cin>>s,strcmp(s,"0"))
{
res = 0;
int len = strlen(s);
int k = 0;
for(int i = len - 1;i >= 0;i--)
{
int temp = s[i] - '0';
res += temp * (pow(2,k+1) - 1);
k++;
}
cout<<res<<endl;
}
return 0;
}
本文提供了一种解决UVa575 Skew Binary问题的有效算法。通过C++实现,该算法能够将Skew Binary数转换为十进制数。文章中的代码简洁明了,易于理解。
734

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



