题解:
模拟。
照着他的过程(看看提示)模拟下去就行了。
{
ID:h1956701
LANG:PASCAL
PROB:gift1
}
var n,i,k,j,m:longint;
s:ansistring;
a:array[0..11]of ansistring;
b,c:array[0..11]of longint;
function find(s:ansistring):longint;
var i:longint;
begin
for i:=1 to n do
if a[i]=s then exit(i);
end;
begin
assign(input,‘gift1.in‘);
reset(input);
assign(output,‘gift1.out‘);
rewrite(output);
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do
begin
readln(s);
k:=find(s);
readln(b[k],m);
for j:=1 to m do
begin
readln(s);
inc(c[find(s)],b[k] div m);
end;
if m>0 then
b[k]:=b[k]-b[k] mod m;
end;
for i:=1 to n do writeln(a[i],‘ ‘,c[i]-b[i]);
close(input);
close(output);
end.
时间: 2024-10-28 10:45:22