Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
126448 | 涛涛老师 | 十进制转R进制 | C++ | Accepted | 1 MS | 276 KB | 748 | 2025-07-19 11:27:59 |
#include <iostream> #include <vector> #include <math.h> #include <algorithm> using namespace std; char transform_char(int n) { char result; if (n < 10) result = '0' + n; else result = 'A' + (n - 10); return result; } void arbitrary_radix(int n, int radix) { int temp; int remainder; vector<char> result; temp = n; while (1) { if (temp < radix) { result.push_back(transform_char(temp)); break; } remainder = temp % radix; temp = temp/ radix; result.push_back(transform_char(remainder)); } reverse(result.begin(), result.end()); for (int i = 0; i < result.size(); i++) cout << result[i]; } int main() { int n, radix; cin >> n >> radix; arbitrary_radix(n, radix); return 0; }