Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
99039 柯昊阳 K进制数转L进制数 C++ 通过 100 0 MS 260 KB 631 2023-08-21 16:25:57

Tests(5/5):


#include <bits/stdc++.h> using namespace std; stack<char> stk; int main(){ int a,c; string b; while(cin>>a>>b>>c){ int ans = 0; int d = 0; for(int i = b.size()-1;i>=0;i--){ if(b[i]>='A'&&b[i]<='Z'){ ans+=int(b[i]-'A'+10)*pow(a,d); d++; } else { ans+=int(b[i]-'0')*pow(a,d); d++; } } //cout<<ans<<endl; while(ans>0){ int sss = ans%c; // cout<<sss<<" "; if(sss>=10){ stk.push(char(sss-10+'A')); } else stk.push(char(sss+48)); ans = ans/c; } while(!stk.empty()){ cout<<stk.top(); stk.pop(); } cout<<endl; } return 0; }


测评信息: