Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
325590 黄浙峰老师 【C6-3】进制转换 C++ 通过 100 1 MS 260 KB 517 2025-06-07 13:00:15

Tests(10/10):


#include<iostream> #include<algorithm> #include<string> using namespace std; int main(){ int n,m; string s,ans; cin>>n>>s>>m; int x=0; for(int i=0;i<s.size();i++){ int t=s[i]>='0'&&s[i]<='9'? s[i]-'0':s[i]-'A'+10; x=x*n+t; } while(x>0){ int t=x%m; if(t<10) ans.push_back('0'+t); else ans.push_back('A'+t-10); x/=m; } reverse(ans.begin(),ans.end()); cout<<ans<<endl; return 0; }


测评信息: