这一题就是判断的时候有一些麻烦,其他的都容易打出来,不过这些代码都很容易想得到。
var
a,b:array[1..10] of string[14];
c:array[1..10,1..3] of longint;
d:array[1..10,1..9] of string[14];
n,i,j,k:longint;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
begin
readln(b[i]);
readln(c[i,1],c[i,2]);
for j:=1 to c[i,2] do
readln(d[i,j]);
end;
for i:=1 to n do
begin
if c[i,1]>0 then
begin
for j:=1 to c[i,2] do
begin
k:=1;
while d[i,j]<>b[k] do inc(k);
c[k,3]:=c[k,3]+c[i,1] div c[i,2];
end;
if c[i,2]=0 then c[i,3]:=c[i,3]+c[i,1]
else c[i,3]:=c[i,3]+c[i,1] mod c[i,2];
end;
end;
i:=1;
while i<=n do
begin
for j:=1 to n do
if a[i]=b[j] then
begin
writeln(b[j],' ',c[j,3]-c[j,1]);
inc(i);
break;
end;
end;
end.