// 1019. General Palindromic Number.cpp: 主项目文件。 #include "stdafx.h" #include <cstdio> bool isPalindromic(int *arr, int length){ for(int i=0,j=length-1;i<=j;i++,j--){ if(arr[i]!=arr[j]) return false; } return true; } int main() { int num,base; scanf("%d%d",&num,&base); if(num==0){ printf("Yes\n0\n"); return 0; } int aa[103],cnt=0; while(num){ aa[cnt++]=num%base; num/=base; } bool tag=isPalindromic(aa,cnt); if(tag) puts("Yes"); else puts("No"); for(int i=cnt-1;i>=0;i--){ if(i!=cnt-1) printf(" "); printf("%d",aa[i]); } printf("\n"); return 0; }
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240813180353098-2140851696.jpg)