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

Common Board

What wrong in this??? Why I'm get WA??? I Think, what my program is right... Please help me... (Problem 1118)
Posted by Evgeny Reshetnikov 14 Jan 2002 21:37
This is my program:

{$N+}
Program n1118;
  Var
    i,j,q,w,sum,ans:longint;
    triv:extended;

Procedure Input;
  Begin
    ReadLn(i,j);
  End;

Procedure Solve;
  Begin
    triv:=1000000;
    ans:=0;
    For q:=j downto i Do
      Begin
        sum:=1;
        For w:=2 to (q div 2) Do
          If (q mod w)=0 Then
            sum:=sum+w;
        If sum=1 Then
          Begin
            Write(q);
            Halt;
          End;
        If sum/q<triv Then
          Begin
            triv:=sum/q;
            ans:=q;
          End;
      End;
    Write(ans);
  End;

Begin
  Input;
  Solve;
End.
Triviality of 1 = 0
Posted by Wrong Answer Limit Exceeded 14 Jan 2002 21:54
> This is my program:
>
> {$N+}
> Program n1118;
>   Var
>     i,j,q,w,sum,ans:longint;
>     triv:extended;
>
> Procedure Input;
>   Begin
>     ReadLn(i,j);
>   End;
>
> Procedure Solve;
>   Begin
>     triv:=1000000;
>     ans:=0;
>     For q:=j downto i Do
>       Begin
>         sum:=1;
>         For w:=2 to (q div 2) Do
>           If (q mod w)=0 Then
>             sum:=sum+w;
>         If sum=1 Then
>           Begin
>             Write(q);
>             Halt;
>           End;
>         If sum/q<triv Then
>           Begin
>             triv:=sum/q;
>             ans:=q;
>           End;
>       End;
>     Write(ans);
>   End;
>
> Begin
>   Input;
>   Solve;
> End.
Tnaks! I've got AC!
Posted by Evgeny Reshetnikov 16 Jan 2002 13:33