| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 117030 | 陈家宝 | K进制数转L进制数 | C++ | Accepted | 100 | 0 MS | 256 KB | 535 | 2023-12-21 13:58:39 |
#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; }