7.1 最多因子数
写一个程序扫描一定范围内的数,并确定在此范围内约数个数最多的那个数。不幸的是,这个数和给定的范围都比较大,用简单的方法寻找可能需要较多的运行时间。所以请确定你的算法能在几秒内完成最大范围内的扫描。
输入
只有一行,给出扫描的范围,由下界L和上界U确定,满足2 up
then exit
else begin
j := primes;
x := low - 1; y := up; n := num; t := tot; m := 1;{x为什么要减一}
while true do
begin
inc(m); inc(t, tot);
x := x div j; y := y div j;
if x = y then break;
n := n * j;
try(i + 1, t, n, x + 1, y){为什么I要加一????}
end;
m := 1 shl m; if tot < max div m then exit
end
end;
begin
assign(input, fin); reset(input);
assign(output, fon); rewrite(output);
getprimes;
readln(l, u);
if (l = 1) and (u = 1)
then begin
max := 1;
number := 1
end
else begin
max := 2; number := l;
try(1, 1, 1, l, u)
end;
writeln('Between ', l, ' and ', u, ', ', number, ' has a maximum of ', max, ' divisors.');
close(output); close(input)
end.