-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp1045
47 lines (43 loc) · 741 Bytes
/
p1045
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<bits/stdc++.h>
using namespace std;
const int N=500;
int res[N],a[N];
int p;
void mul(int a[],int b[],int c[])
{
static int tmp[N];
memset(tmp,0,sizeof tmp);
for(int i=0;i<500;i++)
for(int j=0;j<500;j++)
if(i+j<500)
tmp[i+j]+=a[i]*b[j];
for(int i=0,t=0;i<500;i++)
{
t+=tmp[i];
c[i]=t%10;
t/=10;
}
}
void qmi()
{
a[0]=2,res[0]=1;
while(p)
{
if(p&1) mul(a,res,res);
mul(a,a,a);
p>>=1;
}
res[0]--;
for(int i=499,j=0;j<10;j++)
{
for(int k=0;k<50;k++,i--) cout<<res[i];
cout<<endl;
}
}
int main()
{
cin>>p;
cout<<int(p*log10(2))+1<<endl;
qmi();
return 0;
}