mmdxm @ 2022-08-15 12:40:44
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int z[1000101],len=1,y[1000101];
void quick(int l){
if(l==1) return;
int k=l>>1,x=0,i,j;
quick(k);
for(i=1;i<=len;i++){
for(j=1;j<=len;j++){
y[i+j-1]+=z[i]*z[j];
y[i+j]+=y[i+j-1]/10;
if(i+j>len&&y[i+j]!=0) len=i+j;
y[i+j-1]%=10;
}
}
for(i=1;i<=len;i++){
z[i]=y[i];
y[i]=0;
}
if(l&1){
for(i=1;i<=len;i++){
z[i]=z[i]*2+x;
x=z[i]/10;
z[i]%=10;
}
if(x!=0){
len++;
z[len]=x;
}
}
}
int main(){
int n,i,j,x=0,k;
scanf("%d",&n);
z[1]=2;
quick(n);
z[1]-=1;
for(i=1;i<=len;i++){
if(z[i]<0){
z[i]+=10;
z[i+1]--;
}
else break;
}
printf("%d\n",len);
for(i=500;i>=1;i--){
printf("%d",z[i]);
if(i%50==0&&i!=500) printf("\n");
}
return 0;
}
by mmdxm @ 2022-08-18 10:36:21
没逝了,我找到问题了虽然不知道为什么
by mmdxm @ 2022-08-18 10:36:49
@Xuzhonghan666
by mmdxm @ 2022-08-18 10:39:32
哦,对了,输出第一行本来应该是第500位到401位,我写成了第500位到第400位
by mmdxm @ 2022-08-18 10:40:07
应该提前换行
by Chtholly_Tree @ 2022-08-18 14:22:48
@liuyufei0925 哦,AC就行。