Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
110526 王思颜 二进制转十进制 C++ Accepted 1 MS 280 KB 244 2025-02-22 11:19:42

Tests(20/20):


Code:

#include<bits/stdc++.h> using namespace std; string a; int main() { cin>>a; int n = a.size(); int x = 0,j = 0; for (int i = n - 1;i >= 0;i--){ if (a[i] == '1'){ x += 1 * pow(2,j); } j++; } cout<<x; return 0; }