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