主题:[请教高手]
我是一个新手,我老师讲了一道题,但我没理解好。
我想请教高手们,请将此题的详细解题思路给我说一下以及相关的数学知识,感激不尽。。
program program2;
var
i, number, ndata, sum: integer;
data: array[1..100] of integer;
procedure solve(s, sign, n: integer);
var i: integer;
begin
for i := s to ndata do begin
inc(sum, sign * (number div (n * data[i])));
solve(i + 1, -sign, n * data[i]);
end;
end;
begin
read(number ,ndata);
sum := 0;
for i := 1 to ndata do read(data[i]);
solve(1, 1, 1);
writeln(sum);
end.
输入:1000 3 5 13 11
输出:
我想请教高手们,请将此题的详细解题思路给我说一下以及相关的数学知识,感激不尽。。
program program2;
var
i, number, ndata, sum: integer;
data: array[1..100] of integer;
procedure solve(s, sign, n: integer);
var i: integer;
begin
for i := s to ndata do begin
inc(sum, sign * (number div (n * data[i])));
solve(i + 1, -sign, n * data[i]);
end;
end;
begin
read(number ,ndata);
sum := 0;
for i := 1 to ndata do read(data[i]);
solve(1, 1, 1);
writeln(sum);
end.
输入:1000 3 5 13 11
输出: