C++ 代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,b;
cin>>n>>b;
int ans[30],i = 0 ;
do{
ans[i++] = n%b;
n /= b;
}while(n!=0);
int flag = 1;
for(int j = 0;j<=i/2;j++){
if(ans[j]!=ans[i-j-1]) flag=0;
}
if(flag == 1) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
for(int j= i-1 ;j>=0 ;j--) {
cout<<ans[j]<<" ";
}
return 0;
}