| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 62869 | 申明智 | 二进制小数转十进制 | C++ | Accepted | 1 MS | 280 KB | 469 | 2023-12-30 14:29:24 |
#include <bits/stdc++.h>. using namespace std; int main () { int ans1=0; double ans2=0; string s; cin>>s; int len=s.size(); int point=s.find("."); if(point==-1) { for(int i=len-1; i>=0; i--) { ans1+=(s[i]-'0')*pow(2,len-1-i); } return 0; } for(int i=point-1; i>=0; i--) { ans1+=(s[i]-'0')*pow(2,point-1-i); } for(int i=point+1; i<len; i++) { ans2+=(s[i]-'0')*pow(2,point-i); } cout<<ans1+ans2; return 0; }