把一张一元钞票换成1分,2分,5分的硬币(每种至少一枚),问有几种分法?

2024-10-28 07:52:13
推荐回答(1个)
回答1:

我也计了第一题,帮我看一看对不对吧

var
i,j,k,m:integer;
for i:=1 to 98 do
for j:=1 to 48 do
for k:=1 to 18 do
if (i*1+j*2+k*5=100)then begin
writeln(i:3,j:3,k:3);
m:=m+1;
end;
writeln(m:3);
readln;
end.

第二题

var
e:real;
sum,n,i:integer;
begin
sum:=1;
readln(n);
for i:=1 to n do
begin
sum:=sum*i;
e:=e+1/sum;
end;
writeln(e:2:9);
readln;
end.