题解 | #skew数#
skew数
http://www.nowcoder.com/practice/5928127cc6604129923346e955e75984
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string skew;
while (cin >> skew)
{
reverse(skew.begin(), skew.end());
int res = 0;
for (int i = 0; i < skew.size(); ++i)
res += (skew[i]-'0') * ((2 << i) - 1); //并不需要去用pow,2的次方直接用位运算即可
cout << res << endl;
}
return 0;
}