Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位大哥用FP过了的,指点一下吧!

Posted by 15pengyi at 2005-05-18 13:38:09 on Problem 1650
的确不知道错哪儿了……
program pku1650;
var r:real;
    n,fz,fm,k:longint;
    b:boolean;
begin
   readln(r);
   readln(n);
   b:=true;
   fz:=1;  fm:=1;
   k:=1;
   while b and(fz/fm<>r) do
      if (k>n)or(trunc(k*r)>n)
       then b:=false
       else begin
               if (trunc(k*r)>0)and(abs(r-trunc(k*r)/k)<abs(r-fz/fm))
                then begin
                        fz:=trunc(k*r);
                        fm:=k;
                     end;
               if (trunc(k*r)<n)and(abs(r-(trunc(k*r)+1)/k)<abs(r-fz/fm))
                then begin
                        fz:=trunc(k*r)+1;
                        fm:=k;
                     end;
               k:=k+1;
            end;
   writeln(fz,' ',fm);
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator