Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
99038 周歆童 K进制数转L进制数 C++ 通过 100 28 MS 39328 KB 768 2023-08-21 16:25:40

Tests(5/5):


#include<bits/stdc++.h> using namespace std; string a; int c[10000000],d,e,f,g,sum,ans; int main() { while(cin>>d>>a>>f){ memset(c,0,sizeof(c)); e=g=sum=ans=0; for(int x=0;x<a.size();x++){ if(a[x]<'A'){ e=pow(d,a.size()-x-1); e*=(a[x]-'0'); sum+=e; } else{ e=pow(d,a.size()-1-x); e*=(a[x]-'A'+10); sum+=e; } } while(sum>0){ c[g++]=sum%f; sum/=f; } for(int x=g-1;x>=0;x--){ if(c[x]>=10)printf("%c",c[x]+'A'-10); else printf("%d",c[x]); } cout<<endl; } return 0; }


测评信息: