标签:
简单题。
#include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<queue> #include<vector> using namespace std; int s[10000],tot; int n,b; bool check() { for(int i=0; i<=tot/2; i++) { if(s[i]!=s[tot-i-1]) return 0; } return 1; } int main() { scanf("%d%d",&n,&b); if(n==0) { printf("Yes\n"); printf("0\n"); } else { tot=0; while(n) s[tot++]=n%b,n=n/b; if(check()) printf("Yes\n"); else printf("No\n"); for(int i=tot-1; i>=0; i--) { printf("%d",s[i]); if(i>0) printf(" "); else printf("\n"); } } return 0; }
PAT (Advanced Level) 1019. General Palindromic Number (20)
标签:
原文地址:http://www.cnblogs.com/zufezzt/p/5499348.html