| ||||||||||
| 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 | |||||||||
Re:用我这个试试吧In Reply To:用我这个试试吧 Posted by:Lighting at 2006-05-05 17:35:54 > #include <stdio.h>
>
> unsigned long getl(int n)
> {
> unsigned long result=0;
> unsigned long r=n;
> while(r>1)
> {
> if(r%2==0)
> {
> r/=2;
> result++;
> continue;
> }
> if(r%2==1)
> {
> r=r*3+1;
> result++;
> continue;
> }
> }
> return(result);
> }
>
> void main()
> {
> int i,j,k;
> int m,n;
> unsigned long max=0,temp;
> while(scanf("%d %d",&i,&j)!=EOF)
> {
> max=0;
> m=i>j?j:i;
> n=i>j?i:j;
> for(k=m;k<=n;k++)
> {
> temp=getl(k);
> if(temp>max)
> max=temp;
> }
> printf("%d %d %ld\n",i,j,max+1);
> }
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator