nzlys04 @ 2024-08-01 14:17:33
#include<bits/stdc++.h>
using namespace std;
#define jw 100000//5位
long long a[100000] = {0, 1};
int main() {
int p, l = 1;
cin >> p;
int t1 = p / 40, t2 = p % 40;
for (int i = 1; i <= t1; i++) {
for (int j = 1; j <= l; j++)
a[j] *= 1099511627776; //2^40
for (int j = 1; j < l; j++) {
if (a[j] >= jw) {
a[j + 1] += a[j] / jw;
a[j] %= jw;
}
}
while (a[l] >= jw) {
a[l + 1] += a[l] / jw;
a[l] %= jw;
l++;
}
// for (int i = l; i > 0; i--)
// cout << a[i];
// cout << endl;
}
for (int i = 1; i <= t2; i++) {
for (int j = 1; j <= l; j++)
a[j] *= 2;
for (int j = 1; j < l; j++)
if (a[j] >= jw) {
a[j + 1] += a[j] / jw;
a[j] %= jw;
}
while (a[l] >= jw) {
a[l + 1] += a[l] / jw;
a[l] %= jw;
l++;
}
}
a[1]--;
while (!a[l])l--;
int ws = l * 5 - 5, b = a[l];
while (b)b /= 10, ws++;
cout << ws << endl;
for (int i = 100; i > 0; i--) {
if (i % 10 == 0 && i != 100)
cout << '\n';
printf("%05lld", a[i]);
}
return 0;
}