| ||||||||||
| 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 | |||||||||
求救啊!!!测试数据对了,i,j大小和区间断点问题注意,可还是WA#include<stdio.h>
void main()
{
long count,n,i,j,max,m,temp,flag=0;
scanf("%ld %ld",&i,&j);
if (i>j)
{
temp=i;
i=j;
j=temp;
flag=1;
}
for (n=i;n<=j;n++)
{
m=n;
count=1;
while (m!=1)
{
if (m%2==0) m=m/2;
else m=3*m+1;
count++;
}
if (count>max) max=count;
}
if (flag==1)
printf("%ld %ld %ld\n",j,i,max);
else printf("%ld %ld %ld\n",i,j,max);
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator