| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 73778 | 杨莹斌 | 二进制转十进制 | C++ | Accepted | 1 MS | 280 KB | 321 | 2024-05-19 16:43:53 |
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int len = s.size(); int a[len]; int j = 0; for(int i = len - 1;i >= 0;i--){ a[j] = s[i] - 48; j++; } int sum = 0; for(int i = len - 1;i >= 0;i--){ sum += pow(2,i) * a[i]; } cout<<sum; return 0; }