Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
48628 舒晨扬 十进制转R进制 C++ Accepted 1 MS 276 KB 489 2023-06-10 15:49:19

Tests(10/10):


Code:

//include<bits/stdc++.h>erase #include<iostream> #include<string> int a[330]; using namespace std; int main(){ //freopen(a.in,"r",stdin); //freopen(b.out,"w",stdout); int n,r; string s = "ABCDEF"; cin >> n >> r; if(n == 0) { cout << "0"; } else{ int c = 0,t = n;; while(t != 0){ a[c] = t % r; t /= r; c++; } for(int i = c - 1;i >=0;i--){ if(a[i] >= 10){ cout << s[a[i] % 10]; } else{ cout << a[i]; } } } return 0; }