PAT (Advanced Level) 1019. General Palindromic Number (20)
Posted Fighting Heart
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT (Advanced Level) 1019. General Palindromic Number (20)相关的知识,希望对你有一定的参考价值。
简单题。
#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)的主要内容,如果未能解决你的问题,请参考以下文章
PAT (Advanced Level) 1025. PAT Ranking (25)