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

1207 1AC PASCAL

Posted by aiouniya at 2012-08-23 16:00:39 on Problem 1207
function pa(n:longint):longint;
var
  len:longint;
begin
  len:=1;
  while n<>1 do
    begin
      if odd(n) then n:=n*3+1
      else n:=n div 2;
      inc(len);
    end;
  pa:=len;
end;
var
  n,m,tmp,tn,tm,i,max,j:longint;
  a:boolean;
begin
  while not eof do
    begin
      a:=true;
      readln(n,m);
      tn:=n;
      tm:=m;
      max:=-1;
      if n>m then begin a:=false;tmp:=n;n:=m;m:=tmp; end;
      for  i:=n to m do
      begin
        j:=pa(i);
        if max<j then max:=j;
      end;
      writeln(tn,' ',tm,' ',max);
    end;
end.



顶起PASCAL!!!

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