题解 | skew数
skew数
https://www.nowcoder.com/practice/5928127cc6604129923346e955e75984
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
using namespace std;
int multiple(int k) {
int er = 1;
for (int i = 0; i <k; i++) {
er = er * 2;
}
return er;
}
int main() {
char arr[100];
string str;
int total = 0;
while (scanf("%s", &arr) != EOF) {
str = arr;
for (int i = 0; i < str.size(); ++i) {
int multi = multiple(str.size() - i);
if (str[i] == '2') {
total += 2 * (multi - 1);
break;
}
else if (str[i] == '1') {
total += multi - 1;
}
}
printf("%d\n", total);
total=0;
}
return 0;
}
#shit#
