题目描述
题解:
这一题我只有50。
100%:根据之前的“(q1+1)(q2+1)(q3+1)…(qn+1)”,很容易得出状态转移方程f(x)(y)=f(x-1)(y/(k+1))*p_x^k (1<=k<=y)(k+1|y),再优化一下就AC。
代码:
var
a:array[1..100000000] of longint;
b:array[1..500000] of longint;
l,r,max,ans:longint;
i,j:longint;
procedure main;
begin
a[1]:=1;
for i:=2 to r do a[i]:=2;
for i:=2 to trunc(sqrt(r)) do
for j:=i to r div i do
if i=j then inc(a[i*j])
else
a[i*j]:=a[i*j]+2;
end;
begin
readln(l,r);
main;
max:=1;
for i:=2 to r do
if a[i]>max then
begin
if i>=l then begin inc(ans);b[ans]:=i;end;
max:=a[i];
end;
write(ans);
for i:=1 to ans do
write(' ',b[i]);
writeln;
end.