题解 | #Skew数#
Skew数
https://www.nowcoder.com/practice/7b6586ac8f614aafbe2e0896e82ac0c1
#include <cstdio> #include <string> #include <iostream> // 引入iostream以使用cin和cout #include "cmath" using namespace std; int main() { string number; unsigned long long int answer = 0; unsigned long long int temp = 0; while (getline(cin, number) && !cin.eof()) { // 使用cin代替number,并检查cin的状态 string end="0"; if(number==end){break;} for (int i = 0; i < number.size(); i++) { if (number[i] != '0') { temp = (pow(2, number.size() - i) - 1); answer = answer + (number[i] - '0') * temp; } } printf("%lld\n", answer); answer = 0; } return 0; }