Files
python/TangDou/XiTi/1155.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

28 lines
507 B
C++

#include <bits/stdc++.h>
using namespace std;
int main() {
int p, q, n;
cin >> p >> n >> q;
//现将P进制转换为十进制
int t = 0, f = 1;
while (n != 0) {
t = (n % 10) * f + t;
f = f * p;
n = n / 10;
}
//现在将十进制转换为Q进制
int y[100], num = 0;
do {
y[num++] = t % q;
t = t / q;
} while (t != 0);
//输出结果
for (int i = num - 1; i >= 0; i--) {
cout << y[i];
}
return 0;
}