1019. General Palindromic Number

#include<iostream>
#include<vector>
using namespace  std;
int main(){
  int n,b;cin>>n>>b;
  if(!n)cout<<"Yes"<<endl<<0;
  else
    {
      vector<int>ret;
      while(n){
	ret.push_back(n%b);
	n/=b;}
      bool ok=true;
      for(int i=0,cnt=ret.size();i<cnt/2;++i)
	if(ret[i]!=ret[cnt-1-i])
	  ok=false;
      cout<<(ok?"Yes":"No")<<endl;
      for(auto it=ret.rbegin();it!=ret.rend();++it){
	if(it!=ret.rbegin())cout<<' ';
	cout<<*it;}//for
    }
  return 0;
}

你可能感兴趣的:(1019. General Palindromic Number)