题解 | #skew数#

skew数

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

#include <bits/stdc++.h>

using namespace std;

int main(){
	string str;
	
	while(getline(cin,str)){
		int ans = 0;
		for(int i = str.size() - 1,j = 1;i >= 0;i --){
			ans += (str[i] - '0') * (pow(2,j) - 1);
			j ++;
		}
		cout << ans << endl;
	}
	return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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