提交时间:2021-06-19 19:44:48

运行 ID: 20676

#include <bits/stdc++.h> using namespace std; int k,m; string a="1",b="1",c; int main() { scanf("%d,%d",&k,&m); for(int i=1; i<k; i++) { int x=0; for(int i=a.size()-1; i>=0; i--) { int a1=(int)(a[i]-'0'); a1=a1*2+x; x=a1/10; a1%=10; a[i]=(char)(a1+'0'); } if(x)a=(char)(x+'0')+a; } for(int i=1; i<=m; i++) { int x=0; for(int i=b.size()-1; i>=0; i--) { int b1=(int)(b[i]-'0'); b1=b1*2+x; x=b1/10; b1%=10; b[i]=(char)(b1+'0'); } if(x)b=(char)(x+'0')+b; } while(a.size()<b.size())a='0'+a; while(b.size()<a.size())b='0'+b; int len=a.size(); int x=0; for(int i=len-1; i>=0; i--) { int a1=(int)(a[i]-'0'); int b1=(int)(b[i]-'0'); int c1=b1-a1-x; x=0; if(c1<0) { x=1; c1+=10; } c=(char)(c1+'0')+c; } if(c.size()<=6) { cout<<c<<endl; } else { cout<<c.substr(0,3)<<','<<c.substr(c.size()-3,3)<<endl; } }