- 宁静与九连环
- 2009-06-29 09:04:45 @
有公式
1/3(2^(n+1)
可得以下程序
var
n,i,k,j:integer;
a:array [1..10000] of integer;
begin
read(n);
a[1]:=1;
k:=1;
for j:=1 to n+1 do
begin
a[1]:=a[1]*2;
for i:=2 to k do
begin
a[i]:=a[i]*2;
a[i]:=a[i]+a div 10;
a:=a mod 10;
end;
while a[k]>=10 do
begin
k:=k+1;
a[k]:=a[k-1] div 10;
a[k-1]:=a[k-1] mod 10;
end;
end;
j:=0;
for i:=k downto 1 do
begin
a[i]:=a[i]+j*10;
j:=a[i] mod 3;
a[i]:=a[i] div 3;
end;
while a[k]=0 do k:=k-1;
for i:=k downto 1 do
write(a[i]);
end.
1 条评论
-
389885660 LV 5 @ 2009-10-01 16:30:57
program lsy;
type
arr=record
ch:char;
l,r:integer;
end;
var
a:array[1..1024] of arr;
s1,s2,cha:char;
i,j,m,n:integer;procedure fox(k:integer);
begin
if k0 then
begin
write(a[k].ch);
fox(a[k].l);
fox(a[k].r);
end;
end;begin
readln(n);
if n=0 then
begin
read(cha);
if cha='1' then write('B')
else write('Z');
halt;
end;
m:=1;
for i:=1 to n do m:=m*2;
for i:=m to 2*m-1 do
begin
read(cha);
if cha='1' then a[i].ch:='B'
else a[i].ch:='Z';
a[i].l:=0;a[i].r:=0;
end;
for i:=m-1 downto 1 do
begin
a[i].l:=2*i; a[i].r:=2*i+1;
s1:=a[a[i].l].ch;
s2:=a[a[i].r].ch;
if (s1='F') or (s2='F') then a[i].ch:='F'
else
if s1=s2 then if s1='Z' then a[i].ch='Z'
else a[i].ch='B'
else a[i].ch='F';
end;
fox(1);
end.各位高手可以帮忙看看哪里错了吗呜
- 1