ACM 基础练习 3n+1 问题 运行正确 但提交后答案错误 求大神指导
#include<stdio.h>int main()
{
long i,j,k,m,n,N;
while(scanf("%ld %ld",&i,&j)!=EOF)
{
N=1;
if(i>0&&j<1000000)
{
for(m=i;m<=j;m++)
{
n=1;
k=m;
while(k!=1)
{
if(k%2==0)
k=k/2;
else
k=k*3+1;
n++;
}
if(n>N)
N=n;
}
printf("%ld %ld %ld\n",i,j,N);
}
}
return 0;
}