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 |
求高手优化var i,j,n,t,k:longint; a:array[1..5842] of int64; function pd(x:longint):boolean; begin while x mod 2=0 do x:=x div 2; while x mod 3=0 do x:=x div 3; while x mod 5=0 do x:=x div 5; while x mod 7=0 do x:=x div 7; if x=1 then exit(true) else exit(false); end; begin readln(n); repeat i:=0; j:=0; k:=1; repeat inc(i); if pd(i) then begin inc(j); a[k]:=i; inc(k); end; until j=n; for i:=1 to k do begin t:=n mod 10; if (t =1)and(n<>11) then begin writeln('The ',n,'st humbil is ',a[n],'.'); break; end; if t =2 then begin writeln('The ',n,'nd humbil is ',a[n],'.'); break; end; if t =3 then begin writeln('The ',n,'rd humbil is ',a[n],'.'); break; end; if (t<>1)and(t<>2)and(t<>3)or(n=11)then begin writeln('The ',n,'th humble is ',a[n],'.'); break; end; end; readln(n); until n=0; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator