比赛 noip-081029 评测结果 AAATTAATTT
题目名称 最多因子数 最终得分 50
用户昵称 Oo湼鞶oO 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-29 21:18:02
显示代码纯文本
{*******************************************}
{* Program name: divisors                  *}
{* Input file: divisors.in                 *}
{* Ouptut file: divisors.out               *}
{* Date: 2008.10.29                        *}
{* Programmer: Peng Bo                     *}
{*******************************************}
program divisors;
const
  filename='divisors.';
type
  jl=record
       p,d:longint;
     end;
var
  f:text;
  l,u:longint;
  g:jl;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure main;
var
  i,t:longint;
  {--------------------------}
function howmany(n:longint):longint;
var
  i,t:longint;
begin
  t:=2;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0
    then
      t:=t+2;
  if frac(sqrt(n))=0
  then
    dec(t);
  howmany:=t;
end;{howmany}
  {--------------------------}
begin
  for i:=l to u do
  begin
    t:=howmany(i);
    if t>g.d
    then
    begin
      g.d:=t;
      g.p:=i;
    end;{then}
  end;{for}
end;{main}
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
  assign(f,filename+'in');
  reset(f);
  read(f,l,u);
  close(f);
  {===========}
  g.d:=0;
  main;
  {===========}
  assign(f,filename+'out');
  rewrite(f);
  write(f,'Between ',l,' and ',u,',',g.p,' has a maximum of ',g.d,' divisors.');
  close(f);
end.