You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
const int N = 1e5 + 10;
|
|
|
|
|
int a[N], al;
|
|
|
|
|
int b[N], bl;
|
|
|
|
|
|
|
|
|
|
void mul(int a[], int &al, int b[], int bl) {
|
|
|
|
|
int c[N] = {0}, cl = al + bl;
|
|
|
|
|
for (int i = 1; i <= al; i++)
|
|
|
|
|
for (int j = 1; j <= bl; j++)
|
|
|
|
|
c[i + j - 1] += a[i] * b[j];
|
|
|
|
|
|
|
|
|
|
int t = 0;
|
|
|
|
|
for (int i = 1; i <= al + bl; i++) {
|
|
|
|
|
t += c[i];
|
|
|
|
|
c[i] = t % 10;
|
|
|
|
|
t /= 10;
|
|
|
|
|
}
|
|
|
|
|
memcpy(a, c, sizeof c);
|
|
|
|
|
al = min(500, cl);
|
|
|
|
|
//前导0
|
|
|
|
|
while (al > 1 && a[al] == 0) al--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//快速幂+高精度 x^k
|
|
|
|
|
void qmi(int x, int k) {
|
|
|
|
|
a[++al] = 1, b[++bl] = x; // 2 ^100 b[1]=2
|
|
|
|
|
while (k) {
|
|
|
|
|
if (k & 1) mul(a, al, b, bl);
|
|
|
|
|
k >>= 1;
|
|
|
|
|
mul(b, bl, b, bl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
//计算 2^p-1的值
|
|
|
|
|
int p;
|
|
|
|
|
cin >> p;
|
|
|
|
|
//利用快速幂,计算2^p
|
|
|
|
|
qmi(2, p);
|
|
|
|
|
//最后一位减去一个1,因为2^p最后一位肯定不是0,所以减1不会产生借位,直接减去即可!
|
|
|
|
|
a[1]--;
|
|
|
|
|
|
|
|
|
|
//一共多少位
|
|
|
|
|
printf("%d\n", (int)(p * log10(2) + 1));
|
|
|
|
|
|
|
|
|
|
for (int i = 500; i; i--) {
|
|
|
|
|
printf("%d", a[i]);
|
|
|
|
|
//该换行了,就是到了第二行的行首
|
|
|
|
|
if ((i - 1) % 50 == 0) puts("");
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|