题解 | #skew数#

skew数

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

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

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

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务