#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool check(vector<int>&t){
int s=t.size();
for(int i=0,j=s-1;i<j;i++,j--){
if(t[i]!=t[j])return false;
}
return true;
}
vector<int>add(vector<int>&a,vector<int>&b){
vector<int>c;
int t=0;
for (int i = 0; i < a.size(); i ++ )
{ int s=a[i]+b[i]+t;
c.push_back(s%10);
t=s/10;
}
if (t) c.push_back(t);
return c;
}
int main()
{
string A;
int k;
vector<int> a;
cin >> A >>k;
for (int i = A.size() - 1; i >= 0; i -- ) a.push_back(A[i] - '0');
int res=0;
if(!check(a)){
while(res<k){
res++;
vector<int> b(a.rbegin(),a.rend());
a=add(a,b);
if(check(a))break;
}
}
for (int i = a.size() - 1; i >= 0; i -- ) cout << a[i];
cout<<endl;
cout<<res<<endl;
return 0;
}
06-23
273
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
07-22
314
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
11-09
1046
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
11-08
954
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
11-10
644
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)