|
|
back to boardWhat can be wrong? 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 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. |
|
|