wyhbb163 2010-07-25 03:11:00
点我顶贴
收藏
删除
这个题目,才对了两个点,有两个错是因为比答案少,这个我后来想明白了,但是,为什么会有比答案多的情况??
program nailao;
var
a:array[1..4] of integer;
s1,s2,s3,i:integer;
begin
for i:=1 to 4 do read(a[i]);
if a[2]<a[3] then s:=s+a[2] else s:=s+a[3];
if a[1]<a[4] then s:=s+a[1] else begin
s:=s+a[4];
a[1]:=a[1]-a[4];
end;
s:=s+a[1] div 5;
writeln(s);
end.
#1 maxwzh@2010-07-25 03:11:00
15642
回复
删除
program sl ;
var a,b,c,d,tot:integer;
begin
readln(a,b,c,d);
while (a>0)and(d>0) do
begin
inc(tot);
dec(a);dec(d);
end;
while (b>0)and(c>0) do
begin
inc(tot);
dec(b);dec(c);
end;
while (a>0)and(b>=2) do
begin
inc(tot);
dec(a);dec(b,2);
end;
while (a>=2)and(c>0) do
begin
inc(tot);
dec(a,2);dec(c);
end;
while (a>=3)and(b>0) do
begin
inc(tot);
dec(a,3);dec(b);
end;
while (a>=5) do
begin
inc(tot);
dec(a,5);
end;
writeln(tot);
end.