jxcakak @ 2016-11-08 16:18:38
type
bignum=array[1..500] of longint;
var
p,i:longint;
a:bignum;
function cheng(x,y:bignum):bignum;
var
i,j,p:longint;
z:array[1..1010] of longint;
begin
fillchar(cheng,sizeof(cheng),0);
fillchar(z,sizeof(z),0);
for i:=1 to 500 do
begin
p:=0;
for j:=1 to 500 do
begin
z[i+j-1]:=z[i+j-1]+x[i]*y[j]+p;
p:=z[i+j-1] div 10;
z[i+j-1]:=z[i+j-1] mod 10;
end;
z[i+j]:=p;
end;
for i:=1 to 500 do cheng[i]:=z[i];
end;
function mi(x:longint):bignum;
var
p,q:bignum;
i:longint;
begin
fillchar(mi,sizeof(mi),0);
fillchar(p,sizeof(p),0);
mi[1]:=1;
if x=1 then
begin
mi[1]:=2;
exit;
end;
i:=1;
p[1]:=2;
q:=mi(x div 2);
if x mod 2=1 then
begin
mi:=cheng(mi,q);
mi:=cheng(mi,q);
mi:=cheng(mi,p);
end
else
begin
mi:=cheng(mi,q);
mi:=cheng(mi,q);
end;
end;
begin
readln(p);
writeln(trunc(p*ln(2)/ln(10))+1);
a:=mi(p);
a[1]:=a[1]-1;
for i:=1 to 500 do
begin
write(a[501-i]);
if i mod 50=0 then writeln;
end;
end.
by jxcakak @ 2016-11-08 16:37:29
type
bignum=array[1..500] of longint;
var
p,i:longint;
a:bignum;
function cheng(x:bignum):bignum;
var
i,j,a:longint;
z:array[1..1000] of longint;
begin
fillchar(z,sizeof(z),0);
for i:=1 to 500 do
begin
a:=0;
for j:=1 to 500 do
begin
z[i+j-1]:=z[i+j-1]+x[i]*x[j]+a;
a:=z[i+j-1] div 10;
z[i+j-1]:=z[i+j-1] mod 10;
end;
z[i+j]:=a;
end;
for i:=1 to 500 do cheng[i]:=z[i];
end;
function cheng2(x:bignum):bignum;
var
i,a:longint;
begin
fillchar(cheng2,sizeof(cheng2),0);
a:=0;
for i:=1 to 500 do
begin
cheng2[i]:=x[i]*2+a;
a:=cheng2[i] div 10;
cheng2[i]:=cheng2[i] mod 10;
end;
end;
function mi(x:longint):bignum;
var
q:bignum;
i:longint;
begin
fillchar(mi,sizeof(mi),0);
mi[1]:=1;
if x=1 then
begin
mi[1]:=2;
exit;
end;
i:=1;
q:=mi(x div 2);
if x mod 2=1 then
begin
mi:=cheng(q);
mi:=cheng2(mi);
end
else
begin
mi:=cheng(q);
end;
end;
begin
readln(p);
writeln(trunc(p*ln(2)/ln(10))+1);
a:=mi(p);
a[1]:=a[1]-1;
for i:=1 to 500 do
begin
write(a[501-i]);
if i mod 50=0 then writeln;
end;
end.
by Toclhu @ 2020-04-21 14:59:32
䯌焸