提交时间:2023-11-17 13:43:29
运行 ID: 110865
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { char a1[50005]; int a[50005],b[50005],c[50005],a2,b2,c2=1,d,e,x; long long u,v; bool p=1; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); cin>>a1>>v; a2=strlen(a1); for(d=0;d<=a2-1;d++) a[a2-d]=a1[d]-48; a[1]-=1; c[1]=1; for(u=1;u<=v;u++) { for(d=1;d<=c2;d++) b[d]=c[d]; b2=c2; for(d=1;d<=a2;d++) { x=0; for(e=1;e<=b2;e++) { c[d+e-1]=a[d]*b[e]+x+c[d+e-1]; x=c[d+e-1]/10; c[d+e-1]%=10; } c[d+b2]=x; } c2=a2+b2; if(c2>=1000) c2=1000; while(c[c2]==0&&c2>1) c2--; } for(d=c2;d>=1;d--) cout<<c[d]; return 0; }