主题:急,等着用!!!!能人请进!!
求 2 的N 次方,N 比较大,为节省时间,用了二分快速取幂,但是 ERROR 201
type ty=array[0..1000]of integer;
var ans:array[0..1000]of ty;
i,j,n:integer;
procedure chen(a,b,c:integer);
var i,j,k,w:integer;
begin
if a=1 then exit;
fillchar(ans[a],sizeof(ans[a]),0);
w:=ans[b][0]+ans[c][0];
for i:=1 to ans[b][0] do
for j:=1 to ans[c][0]do
begin
k:=ans[a][i+j-1]+ans[b][i]*ans[c][j];
ans[a][i+j-1]:=ans[a][i+j-1]+k mod 10;
ans[a][i+j]:=ans[a][i+j]+k div 10;
end;
while ans[a][w]=0 do dec(w);
ans[a][0]:=w;
end;
procedure mmm(x:integer);
begin
if x=0 then exit;mmm(x div 2);
chen(x,x div 2,x div 2);
if odd(x) then chen(x,x div 2,1);
exit;
end;
begin
readln(n);
fillchar(ans,sizeof(ans),0);
ans[1][0]:=1;ans[1][1]:=2;
mmm(n);
for i:=ans[n][0] to 1 do
write(ans[n][i]);
writeln;
end.
type ty=array[0..1000]of integer;
var ans:array[0..1000]of ty;
i,j,n:integer;
procedure chen(a,b,c:integer);
var i,j,k,w:integer;
begin
if a=1 then exit;
fillchar(ans[a],sizeof(ans[a]),0);
w:=ans[b][0]+ans[c][0];
for i:=1 to ans[b][0] do
for j:=1 to ans[c][0]do
begin
k:=ans[a][i+j-1]+ans[b][i]*ans[c][j];
ans[a][i+j-1]:=ans[a][i+j-1]+k mod 10;
ans[a][i+j]:=ans[a][i+j]+k div 10;
end;
while ans[a][w]=0 do dec(w);
ans[a][0]:=w;
end;
procedure mmm(x:integer);
begin
if x=0 then exit;mmm(x div 2);
chen(x,x div 2,x div 2);
if odd(x) then chen(x,x div 2,1);
exit;
end;
begin
readln(n);
fillchar(ans,sizeof(ans),0);
ans[1][0]:=1;ans[1][1]:=2;
mmm(n);
for i:=ans[n][0] to 1 do
write(ans[n][i]);
writeln;
end.