Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
166077 | 王容宇 | K进制数转L进制数 | C++ | 通过 | 100 | 0 MS | 252 KB | 531 | 2024-08-19 09:45:38 |
#include <bits/stdc++.h> using namespace std; long long a[4][17]; int main() { int k, l; string n; while(cin >> k >> n >> l) { long long sum = 0; for(int i = 0; i<n.size(); i++) { int x; if(n[i]<='9') { x=n[i]-'0'; } else { x=n[i]-'A'+10; } sum=sum*k+x; } string ans; while(sum) { char c; if(sum%l<=9) { c=sum%l+'0'; } else { c=sum%l+'A'-10; } ans=c+ans; sum/=l; } cout << ans << endl; } return 0; }