把一张一元钞票换成1分,2分,5分的硬币(每种至少一枚),问有几种分法?
问题描述:
把一张一元钞票换成1分,2分,5分的硬币(每种至少一枚),问有几种分法?
e=1+1/2!+1/3!+...1/n!
两题用PASCAL语言编程,
第一题以解决,请回答第二题
答
我也计了第一题,帮我看一看对不对吧
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.