| ||||||||||
| 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 | |||||||||
用我这个试试吧In Reply To:帮忙看看为什么总是Output Limit Exceed吧 Posted by:90303125 at 2004-01-03 11:19:12 #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