Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
93964 | 孙嘉言 | 二进制转十进制 | C++ | Accepted | 1 MS | 280 KB | 283 | 2024-10-19 16:40:34 |
#include <iostream> #include <cstring> #include <cmath> using namespace std; int main(){ int ans=0; char b[64]; cin>>b; int len=strlen(b); for(int i=0,j=len-1;i<len&&j>=0;i++,j--){ ans+=(b[j]-'0')*pow(2,i); }cout<<ans<<endl; return 0; }