ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1118. Nontrivial Numbers

WHI I GOT Time Limit Exceeded. HERE IS A MY PRIGRAM. THENKS
Posted by I am david. Tabo. 24 May 2002 13:31
var sol,gam,i,j,k,m,n:longint;
    min,min1:real;

procedure readdata;
  begin
    readln (n,m);
  end;

procedure solve;
  begin
    min:=n;
    if n=1 then
     begin
       writeln (1);
       halt;
     end;
    min1:=m;
    for i:=n to m do
      begin
        k:=i div 2;
        for j:=2 to k do
          if i mod j = 0 then
            gam:=gam+j;
        min:=gam/i;
        if min1>min then
          begin
            sol:=i;
            min1:=min;
          end;
        gam:=1;
      end;
  end;

procedure print;
  begin
    writeln (sol);
  end;

begin
  readdata;
  solve;
  print;
end.

Re: WHI I GOT Time Limit Exceeded. HERE IS A MY PRIGRAM. THENKS
Posted by raxtinhac 24 May 2002 13:41
try this test   1 1000000    => time limit of course
  O( n * (n + 1) / 4 ) => too big.
Thinhk more little , you will find something interesting.
Good luck