#include<cstdio>#include<cstring>#include<algorithm>#include<string>#include<iostream>using namespace std;struct bign{ int d[100]; int len; bign() { fill(d,d+100,0); len=0; }};bool judge(bign a){ for(int i=0;i<a.len/2;i++) { if(a.d[i]!=a.d[a.len-1-i]) return false; } return true;}bign add(bign a,bign b){ int temp; int carry=0; bign c; for(int i=0;i<a.len||i<b.len;i++) { temp=a.d[i]+b.d[i]+carry; carry=temp/10; c.d[c.len++]=temp%10; } if(carry!=0) c.d[c.len++]=carry; return c;}bign change(string str){ bign a; for(int i=0;i<str.length();i++) { a.d[a.len++]=str[str.length()-1-i]-'0'; } return a;}void PRint(bign a){ for(int i=a.len-1;i>=0;i--) { cout<<a.d[i]; }}int main(){ string str; int k; cin>>str>>k; bign a=change(str); int num=0; while(num<k&&judge(a)==false) { bign b=a; reverse(b.d,b.d+b.len); a=add(a,b); num++; } print(a); printf("/n"); cout<<num; system("pause"); return 0;}
新闻热点
疑难解答