Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
143567 陈家宝 K进制数转L进制数 C++ 通过 100 0 MS 244 KB 524 2024-04-16 16:48:43

Tests(5/5):


#include<bits/stdc++.h> using namespace std; int p,r; string n; int solvea(string s){ int x=1,ans=0; for(int i=s.size()-1;i>=0;i--){ if(s[i]>='A')ans+=(s[i]-'A'+10)*x; else ans+=(s[i]-'0')*x; x*=p; } return ans; } string solveb(int t){ string ans=""; while(t!=0){ int f=t%r; t/=r; if(f<10)ans=((char)(f+'0'))+ans; else ans=((char)((f-10)+'A'))+ans; } return ans; } int main(){ while(cin>>p>>n>>r){ int m=solvea(n); string k=solveb(m); cout<<k<<endl; } return 0; }


测评信息: