水题,水题,又读了假题@_@
判断系数是否构成回文,数组大小开到(30)就够了,(n)最大为(10^9),而基数最小为(2),(2^{30} > 10^9),即最多有(30)位。
相同数码,基数越大,按权展开值越大,即为的单调性。
反之,相同数值,基数越小,位数越多。
ps: (color{green}{AcWing})加了个(0)的corner case
const int N=35;
int a[N];
int n,b;
int main()
{
cin>>n>>b;
int cnt=0;
if(!n) cnt=1;//AcWing
while(n)
{
a[cnt++]=n%b;
n/=b;
}
bool ok=true;
for(int i=0;i<cnt/2;i++)
if(a[i] != a[cnt-1-i])
ok=false;
if(ok) puts("Yes");
else puts("No");
for(int i=cnt-1;i>=0;i--)
{
if(!i) cout<<a[i];
else cout<<a[i]<<' ';
}
//system("pause");
return 0;
}