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

Re:不好意思,这是程序>>>

Posted by YQHull at 2005-08-11 12:34:05 on Problem 2247
In Reply To:难道这答案有错?怎么提交不了啊~~ Posted by:YQHull at 2005-08-11 12:15:34
var
  a:array[1..6000]of longint;
  d:array[1..10]of integer;
  n,t,k:longint;
procedure qsort(l,r:longint);
  var
    i,j,mid,t:longint;
  begin
    i:=l;j:=r;mid:=a[(l+r)div 2];
    repeat
      while a[i]<mid do inc(i);
      while a[j]>mid do dec(j);
      if i<=j then 
        begin
          t:=a[i];a[i]:=a[j];a[j]:=t;
          inc(i);dec(j);
        end;
    until i>j;
    if l<j then qsort(l,j);
    if i<r then qsort(i,r);
  end;
function g(n,now:longint):boolean;
  begin
    if now>2000000000 div n then g:=true
    else g:=false;
  end;
procedure f(n,now:longint);
  begin
    if g(n,now) then exit;
    inc(t);a[t]:=n*now;
    f(n,now*n);
    if n<>7 then f(d[n],now);
  end;
begin 
  d[2]:=3;d[3]:=5;d[5]:=7;
  t:=1;a[1]:=1;
  f(2,1);
  qsort(1,t);
  repeat 
    readln(n);
    if n=0 then break;
    write('The ',n);
    k:=n mod 10;
    if (n<>11)and(k=1) then write('st')
    else if (n<>12)and(k=2) then write('nd')
    else if (n<>13)and(k=3) then write('rd')
    else write('th');
    writeln(' humble number is ',a[n],'.');
  until false;
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