题解 | Skew数

Skew数

https://www.nowcoder.com/practice/7b6586ac8f614aafbe2e0896e82ac0c1?tpId=40&tqId=21382&rp=1&difficulty=&judgeStatus=&tags=/question-ranking

#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main() {
    string str;
    long long res;
    while (cin >> str) {
        if (str == "0")    break;
        res = 0;
        int n = str.size();
        for (int i = 0; i < n; i++) {
            res += (str[i] - '0') * (pow(2, n - i) - 1);
        }
        cout << res << endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

mq2:我倒是觉得这种敞亮一点好。能接受就去不能就不去呗。 完了跟现在“正常”公司一样,hr说的天花乱坠,进去一看根本就是996核动力牛马,想走又没应届生身份了。岂不是更糟。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务