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

求高手优化

Posted by cacacaca at 2011-08-30 16:46:37 on Problem 2247 and last updated at 2011-08-30 16:48:18
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:
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