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

考虑a>b的情况!

Posted by 00130004 at 2003-10-14 22:03:04 on Problem 1207
In Reply To:这样的代码也会wrong answer,天哪! Posted by:scutacm3 at 2003-10-14 20:34:11
"the maximum cycle length for integers between and including i and j"
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 不就是模拟么?难道不对?
> 
> #include <stdio.h>
> 
> int main()
>  {long count,max;
>   long i,t,a,b;
>   while (scanf("%ld %ld",&a,&b)==2)
>    {max=0; 
>     for (i=a;i<=b;i++)
>      {t=i; count=0; 
>       for (;;)
>        {count++;
>         if (t==1) break;
>         if (t%2==1) t=3*t+1;
>         else t=t/2;
>        }   
>       if (max<count) max=count;
>      }
>     printf("%ld %ld %ld\n",a,b,max);
>    }
>   return 1;
>  }

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