#include<iostream>
#include<cmath>
using namespace std;
int main() {
int a, b, res[110] = { 0 };
bool flag = false;
cin >> a >> b;
int i = 0;
while (a != 0) {
res[i++] = a % b;
a /= b;
}
for (int j = i - 1; j >= 0; j--) {
if (res[j] != res[i - j - 1]) flag = true;
}
if (flag == true)
cout << "No"<<endl;
else
cout << "Yes"<<endl;
for (int j = i - 1; j >= 0; j--) {
cout << res[j]<<" ";
}
return 0;
}
【A1019/模拟】进制转换后判断是否回文(进制转换)(水题)
于 2022-03-02 18:49:17 首次发布