My USACO Analysis:Greedy Gift Givers
来源:互联网 发布:1463 端口号 编辑:程序博客网 时间:2024/05/22 12:36
To record the names,I used an array of string.And I used another one to save the numbers that should be printed out.This is also an 'sd hoc' problem-as easy as it could be!
To download this PASCAL source file: gift1.pas
program gift1(input,output);
var
a:array[1..2000]of string;
b:array[1..2000]of integer;
i,j,k,l,n,m,x:integer;
s,s1:string;
begin
assign(input,'gift1.in');
reset(input);
assign(output,'gift1.out');
rewrite(output);
readln(n);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
begin
readln(s);
for j:=1 to n do if a[j]=s then k:=j;
readln(m,l);
if (l<>0) and (m<>0) then
begin
b[k]:=b[k]-m+m mod l;
for j:=1 to l do
begin
readln(s1);
for x:=1 to n do if s1=a[x] then b[x]:=b[x]+m div l;
end;
end
else
for j:=1 to l do readln;
end;
for i:=1 to n do
begin
write(a[i],' ');
writeln(b[i]);
end;
close(input);
close(output);
end.
var
a:array[1..2000]of string;
b:array[1..2000]of integer;
i,j,k,l,n,m,x:integer;
s,s1:string;
begin
assign(input,'gift1.in');
reset(input);
assign(output,'gift1.out');
rewrite(output);
readln(n);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
begin
readln(s);
for j:=1 to n do if a[j]=s then k:=j;
readln(m,l);
if (l<>0) and (m<>0) then
begin
b[k]:=b[k]-m+m mod l;
for j:=1 to l do
begin
readln(s1);
for x:=1 to n do if s1=a[x] then b[x]:=b[x]+m div l;
end;
end
else
for j:=1 to l do readln;
end;
for i:=1 to n do
begin
write(a[i],' ');
writeln(b[i]);
end;
close(input);
close(output);
end.
To download this PASCAL source file: gift1.pas
- My USACO Analysis:Greedy Gift Givers
- Analysis:Greedy Gift Givers
- Greedy Gift Givers(USACO)
- usaco--Greedy Gift Givers
- [USACO] Greedy Gift Givers
- USACO-----Greedy Gift Givers
- USACO | Greedy Gift Givers
- USACO->Greedy Gift Givers
- USACO 1.1-Greedy gift givers
- usaco 1.1:Greedy Gift Givers
- usaco Greedy Gift Givers 字符串
- USACO 1.1 Greedy Gift Givers
- usaco之greedy gift givers
- usaco Greedy Gift Givers 报告
- usaco 1.1 greedy gift givers
- usaco/1.1 Greedy Gift Givers
- USACO 1.1 Greedy Gift Givers
- USACO 1.1 Greedy Gift Givers
- 打算坚持每天写一点文章
- vim 用法简介
- 毕业设计代码设计阶段总结(一)
- 一键清除VC工程生成的垃圾文件
- 对于时间格式 08/21 08:21 用 MM/dd HH:mm 格式无法进行匹配的问题
- My USACO Analysis:Greedy Gift Givers
- Friday the Thirteenth
- 毕业之前要做的20件事
- 如何配置 windows 安装盘需要拷贝的文件
- 改变控件的大小和位置(关于MoveWindow()或SetWindowPos())
- 如何通过命令行注销网络共享
- Analysis:Friday the Thirteenth
- 水晶报表
- 网站架构设计师