题解 | #skew数#

skew数

https://www.nowcoder.com/practice/5928127cc6604129923346e955e75984

pow头文件为#include<cmath>

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

int main() {

    string str = "";

    while (getline(cin, str)) {
        int res = 0;
        int len = str.size();
        for (int i = len - 1, k = 0; i >= 0; i--, k++) {
            res += (str[i] - '0') * (pow(2, k + 1) - 1);
        }
        cout << res << endl;
    }

    return 0;
}

王道考研机试 文章被收录于专栏

包含考研机试打卡表题目

全部评论

相关推荐

牛马人的牛马人生:500一天吗?香麻了
投递字节跳动等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务