| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 163346 | 孔声豪 | 十进制转R进制 | C++ | Accepted | 2 MS | 280 KB | 496 | 2026-10-25 10:20:27 |
#include<bits/stdc++.h> using namespace std; char nc(int x){ if(x>=0&&x<=9)return x+'0'; else if(x>9){ return x+'A'-10; } } int main(){ int z,n; cin>>z>>n; if(z==0||n==0){ cout<<0; return 0; } if(n<=10&&n>=2){ int i=0,a[1000]={}; while(z!=0){ a[i]=z%n; z/=n; i++; } for(int j=i-1;j>=0;j--)cout<<a[j]; } else{ char a[1000]={}; int i=0; while(z){ int t=z%n; a[i]=nc(t); z=z/n; i++; } for(int j=i-1;j>=0;j--)cout<<a[j]; } return 0; }