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 1011. Conductors

What can be wrong?
Posted by shitty.Mishka 14 Oct 2001 01:04
Can you tell me what's wrong with this solution:
Program Conductors;
 Var p,q:Real;
     i:Longint;
Begin
 Read(p,q);
 For i:=1 To 50000 Do
  If Trunc(p*i/100) <> Trunc(q*i/100) Then Begin
   Writeln(i);
   Exit;
  End;
End.

An accepted Pascal solution
Posted by Pete Lupherenko 12 Nov 2001 03:45
VAR
 I         : LongInt;
 One, P, Q : Extended;

BEGIN
  Read ( P, Q );
  I := 1;
  repeat
    One := 100/I;
    if Trunc (Q/One) - Trunc (P/One) > 0
     then begin
       if (Frac(Q/One) > 0)and(Frac(P/One) > 0)
         then begin
           WriteLn ( I );
           Halt ( 0 );
         end;
     end;
    I := I + 1;
  until False;
END.