#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
unsigned long long n,result[1000000] = {0,1},result2[1000000];
int main()
{
freopen("title.in", "r", stdin);
cin >> n;
unsigned long long int nodigits = ceil(n /3.3219280948873), temp = pow(2, 50);//利用10^log10(2)=2计算位数,temp存储2的50次方,方便后面一次乘50次
cout << nodigits << endl;
nodigits = 1;//减少循环
for (int i = 1; i <= n / 50; i++)
{
for (int t = 1; t <= nodigits; t++)
{
result[t] *= temp;
}
for (int t = 1; t <= nodigits; t++)
{
if (result[t] > 9)//进位,主要是这里费时间
{
result[t + 1] += result[t] / 10;
result[t] = result[t] % 10;
if (nodigits < 500 && t == nodigits)
nodigits++;
}
else
break;
}
}
for (int i = 1; i <= n % 50; i++)//要将不满50的乘进去
{
for (int t = 1; t <= nodigits; t++)
{
result[t] *= 2;
}
}
for (int t = 1; t <= nodigits; t++)//一定不超过2的50次方,故将进位放在循环外减少循环次数
{
if (result[t] > 9)
{
result[t + 1] += result[t] / 10;
result[t] = result[t] % 10;
if (nodigits < 500 && t == nodigits)
nodigits++;
}
}
int t = 1;
while (1)//减1操作
{
if (result[t] > 1)
{
result[t] -= 1;
break;
}
else if (result[t] == 0)
{
result[t] = 9;
t++;
}
}
for (int i = 500; i > 0; i--)
{
cout << result[i];
if (!((i - 1) % 50))//防止500时直接换行
cout << endl;
}
return 0;
}
04-19
279