Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪位大哥用FP过了的,指点一下吧!的确不知道错哪儿了…… 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator