https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984
#include<bits/stdc++.h>
using namespace std;
int n,b;
void f(int n,int b)
{
if(!n)
{
cout<<"Yes"<<endl<<0;
return;
}
vector<int>s,temp;
while(n) s.push_back(n%b),n/=b;
temp=s;
reverse(s.begin(),s.end());
if(temp==s) puts("Yes");
else puts("No");
for(int i=0;i<s.size();i++)
{
if(i) cout<<" ";
cout<<s[i];
}
}
int main(void)
{
cin>>n>>b;
f(n,b);
return 0;
}