Unaccepted..哪位神牛帮看下..谢谢

program __Nothing_Left;

const

maxl=30;

var

l:array[1..maxl]of integer;

total:array[0..maxl+1]of integer;

str:string; m,len,s,i:longint;

change:array[1..15,1..15]of integer;

conn:array[0..9,0..9]of boolean;

way:array[0..9]of integer;

procedure init;

var

i,j,p:integer;

begin

readln(str);

read(m);

for i:=1 to m do

begin

read(change);

read(change);

end;

len:=length(str);

p:=len;

for i:=30 downto 30-len+1 do

begin

l[i]:=ord(str[p])-48;{ord('0')}

dec(p);

end;

end;

procedure creatp;

var

i,j:integer;

begin

for i:=0 to 9 do

for j:=0 to 9 do

conn:=false;

for i:=1 to m do

conn[change,change]:=true;

end;

procedure findp;

var

i,j:integer;

begin

for i:=0 to 9 do

begin

for j:=0 to 9 do

if conn then inc(way[i]);

inc(way[i]);

end;

end;

procedure gaojing(k:integer);

var

i,j,f,t,t1,t2:integer;

begin

f:=way[k];

for i:=31 downto 1 do

begin

t:=total[i]*f;

if t>=10 then

begin

t1:=t div 10;

t2:=t mod 10;

total:=total+t1;

total[i]:=t2;

end

else

total[i]:=t;

end;

end;

procedure print;

var

i,j:integer;

begin

j:=0;

while total[j]=0 do

inc(j);

for i:=j to 31 do

write(total[i]);

end;

begin

init;

creatp;

findp;

total[31]:=1;

for i:=30 downto 30-len+1 do

gaojing(l[i]);

print;

end.

1 条评论

  • @ 2009-04-01 18:09:44

    用图的传递闭包。(计算每两个数之间是否可转换)

  • 1

信息

ID
1129
难度
6
分类
高精度 点击显示
标签
递交数
3872
已通过
1107
通过率
29%
被复制
26
上传者