题解 | skew数

#include <math.h>
#include <iostream>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;

int main() {
    unsigned int sum = 0;
    string str;
    while (cin >> str) {
        int idx = str.size() - 1;
        for (auto elem : str) {
            sum += (unsigned int)(elem - '0') * (pow(2, idx + 1) - 1);
            idx--;
        }
        cout << sum << endl;
        sum = 0;
    }

    return 0;
}

全部评论

相关推荐

叁六玖:不买课还想秋招
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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