Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
79623 | hby | 二进制转十进制 | C++ | Accepted | 2 MS | 284 KB | 220 | 2024-07-09 09:46:08 |
#include<bits/stdc++.h> using namespace std; int main(){ char s[100]; int ans=0; cin>>s; int len=strlen(s); for(int i=0,j=len-1;i<len,j>=0;i++,j--){ ans+=((s[i]-'0')*pow(2,j)); }cout<<ans; return 0; }