| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 62862 | 杨宜炜 | 二进制小数转十进制 | C++ | Wrong Answer | 1 MS | 272 KB | 375 | 2023-12-30 14:23:18 |
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; int ans,d=s.find("."),len=s.size(); if(d==-1){ for(int i=len-1;i>=0;i--){ ans+=(s[i]-'0')*pow(2,len-1-i); } }else{ for(int i=d-1;i>=0;i--){ ans+=(s[i]-'0')*pow(2,d-1-i); } for(int i=d+1;i<len-1;i++){ ans+=(s[i]-'0')*pow(2,len-1-i); } } cout<<ans; }
------Input------
0.111
------Answer-----
0.875
------Your output-----
4195118