#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> result;
int n, radix;
scanf("%d%d", &n, &radix);
if (n == 0) printf("Yes\n0");
while (n)
{
result.push_back(n % radix);
n = n / radix;
}
int arr[result.size() - 1];
int index = 0;
for (int i = 0; i < result.size(); i++)
{
if (result[i] != result[result.size() - 1 - i])
{
printf("No\n%d", *(result.end() - 1));
for (auto it = result.begin(); it != result.end() - 1; it++)
{
arr[index++] = *it;
}
for (int j = result.size() - 2; j >= 0; j--)
{
cout << " " << arr[j];
}
break;
}
else
{
printf("Yes\n%d", *result.begin());
for (auto it = result.begin() + 1; it != result.end(); it++)
{
cout << " " << *it;
}
break;
}
}
}
PAT甲级1019
最新推荐文章于 2021-02-18 10:58:51 发布