- 贪婪的送礼者
- 2014-08-12 11:14:54 @
type person=record
money:longint;
num:longint;
give:array[1..100]of string;
name:string;
givemon:longint;
mon:longint;
end;
var
per:array[1..100]of person;
np,i,j,k,n1,n2:longint;
nam,p:string;
begin
readln(np);
for i:=1 to np do
with per[i] do readln(name);
for i:=1 to np do
begin
readln(nam);
for j:=1 to np do
if per[j].name=nam then
begin
readln(n1,n2);
per[j].money:=n1;
per[j].num:=n2;
end;
for k:=1 to n2 do
begin
readln(p);
per[j].give[k]:=p;
end;
end;
for i:=1 to np do
begin
per[i].mon:=per[i].money;
if per[i].num<>0 then begin
per[i].givemon:=per[i].mon div per[i].num;
per[i].money:=per[i].mon mod per[i].num end
else per[i].givemon:=0;
end;
for i:=1 to np do
for j:=1 to per[i].num do
for k:=1 to np do
if per[k].name=per[i].give[j]
then per[k].money:=per[k].money+per[i].givemon;
for i:=1 to np do
with per[i] do
writeln(name,' ',money-mon);
end.
1 条评论
-
试图遗忘 LV 8 @ 2015-05-06 19:06:55
var
money,a:array[1..100] of longint;
name:array[1..100] of string[15];
s:string;
i,j,k,l,n,m,f:longint;
begin
readln(n);
for i:=1 to n do
readln(name[i]);
for i:=1 to n do
begin
readln(s);
for j:=1 to n do
if name[j]=s then k:=j;
j:=k; k:=0;
readln(m,f);
if f<>0 then
begin
money[j]:=(m div f)*f;
m:=m div f;
for j:=1 to f do
begin
readln(s);
for k:=1 to n do
if name[k]=s then inc(a[k],m);
end;
end;
end;
for i:=1 to n do
writeln(name[i],' ',a[i]-money[i]);
end.
- 1