讨论 / 高进度AC
苍蝇 2009-07-04 20:46:00
点我顶贴 收藏 删除
var

a:array[1..100]of integer;

i,j,n,x,l:integer;

procedure jian(x:integer);

var i:integer;

begin

if a[x]<>0 then

begin

dec(a[x]);

for i:=x-1 downto 1 do a[i]:=9;

exit;

end;

jian(x+1);

end;

begin

readln(n);

a[1]:=1;

l:=1;

for j:=1 to n do

begin

x:=0;

for i:=1 to l do

begin

x:=x+a[i]*2;

a[i]:=x mod 10;

x:=x div 10;

end;

if x<>0 then begin l:=l+1;a[l]:=x;end;

end;

if a[1]<>0 then dec(a[1])

else jian(1);

x:=0;

for i:=1 to l do

begin

x:=x+a[i]*2;

a[i]:=x mod 10;

x:=x div 10;

end;

if x<>0 then begin inc(l); a[l]:=x; end;

for i:=l downto 1 do write(a[i]);

readln;

end.

(2^N-1)*2

查看更多回复
提交回复