| ||||||||||
| 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 | |||||||||
数据都对了,但还是wrong answer#include<stdio.h>
int f(int m){
int i=0;
while(1){
if(m==1)
break;
if(m%2!=0)
m=m*3+1;
else
m=m/2;
i++;
}
return i;
}
int num(int i,int j)
{
int m,num[10000],max,n;
for(m=i;m<=j;m++)
num[m-i]=f(m);
for(n=0;n<=j-i;n++)
if(max<num[n])
max=num[n];
return max;
}
main(){
int i,j,sum;
while(scanf("%d %d",&i,&j)!=EOF)
{
sum=num(i,j);
printf("%d %d %d\n",i,j,sum+1);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator