njz1234 @ 2020-08-13 22:55:00
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
string s;
long a[1000],b[1000],q,p,c[501];
void HAA()
{
int i,lena,lenb,x,j;
memset(c,0,sizeof(c));
for(i=1;i<=505;i++)
{
for(j=1;j<=505;j++)
{
c[i+j-1]=a[i]*b[j]+c[i+j-1];
}
}
for(int i=1;i<505;i++)
if(c[i]>=10)
{
c[i+1]+=c[i]/10;
c[i]%=10;
}
memcpy(b,c,sizeof(b));
}
void HAA2()
{
int i,lena,lenb,x,j;
memset(c,0,sizeof(c));
for(i=1;i<=505;i++)
{
for(j=1;j<=505;j++)
{
c[i+j-1]=a[i]*a[j]+c[i+j-1];
}
}
for(int i=1;i<505;i++)
if(c[i]>=10)
{
c[i+1]+=c[i]/10;
c[i]%=10;
}
memcpy(a,c,sizeof(a));
}
void fastPower() {
while (p > 0) {
if (p & 1) {
HAA();
}
p>>= 1;
HAA2();
}
}
int main()
{
int i,sum;
a[1]=2;
b[1]=1;
cin>>p;
q=(int)(log10(2)*p+1);
cout<<q<<endl;
fastPower();
b[1]-=1;
for(i=500;i>=1;i--)
{
if(i%50==0&&i!=500)cout<<endl;
cout<<b[i];
}
}
by njz1234 @ 2020-08-13 22:56:07
样例输出 386 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000104079321946643990819252403273640855 38615262247266704805319112350403608059673360298012 23944173232418484242161395428100779138356624832346 49081399066056773207629241295093892203457731833496 61583550472959420547689811211693677147548478866962 50138443826029173234888531116082853841658502825560 46662248318909188018470682222031405210266984354887 32958028878050869736186900714720710555703168729087
by njz1234 @ 2020-08-13 22:56:57
另一个 756839 输出 227832 18288448825429774219846956862417770870640302475247 92828312585598040121588421297674731878093115313182 16753914541797571068392534875840214937021204750378 89055619401647443568291937923950889819022384242323 28767636683196318572845992994357198238764218257600 09234774987448978769799124034384499030364505405943 84275497234460834579807796823701486980464630401353 54915833132974601389482848422119619724789014565809 44396409267168409183491136926492417685905113427201 26927068487680404055813342880902603793328544677887
by Lucifero @ 2020-08-13 22:57:45
@njz1234 数组开小了吧
by njz1234 @ 2020-08-13 23:07:32
@Gray_White 谢谢!!!对了!!!
by Lucifero @ 2020-08-13 23:15:13
@njz1234 不客气~