比赛 noip-081029 评测结果 AATTTTTTTT
题目名称 最多因子数 最终得分 20
用户昵称 苏轼 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-29 21:44:02
显示代码纯文本
program cch(input,output);
const
 maxf=100000;
var
 u,l,ans,tot,ansi:longint;
 a:array[1..10000] of longint;

procedure sushu(k:longint);
var
 i,j:longint;
 b:array[2..maxf] of boolean;
begin
 fillchar(b,sizeof (b),true);
 for i:=2 to k do
  if b[i] then
   begin
    j:=i+i;
    while j<=k do
     begin
      b[j]:=false;
      inc(j,i);
     end;
    inc(tot);
    a[tot]:=i;
   end;
end;

procedure search(k,ch,q:longint);
var
 i,p,tmp,j:longint;
begin
 if (ch>ans)and(q>=l)and(q<=u) then
  begin
   ans:=ch;
   ansi:=q;
  end;
 if k>tot then exit;
 p:=u div q;
 p:=trunc(ln(p)/ln(a[k]));
 for i:=0 to p do
  begin
   tmp:=1;
   for j:=1 to i do tmp:=tmp*a[k];
   search(k+1,ch*(i+1),q*tmp);
  end;
end;

begin
 assign(input,'divisors.in');
 assign(output,'divisors.out');
 reset(input);
 rewrite(output);
 readln(l,u);
 tot:=0;
 sushu(u);
 ans:=0;
 search(1,1,1);
 write('Between ',l,' and ',u,', ',ansi,' has a maximum of ',ans,' divisors.');
 close(input);
 close(output);
end.