| ||||||||||
| 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>
void main()
{
int i,j,k,n,x,y;
long count,sum;
while(scanf("%d %d",&i,&j)!=EOF)
{
printf("%d %d ",i,j);
sum=0;
if(i<j)
{x=i;y=j;}
if(i>j)
{x=j;y=i;}
for(k=x;k<=y;k++)
{
n=k;
count=1;
while(1)
{
if(n==1)
break;
if(n%2!=0)
{
n=3*n+1;
count++;
}
if(n%2==0)
{
n=n/2;
count++;
}
}
if(count>sum)
sum=count;
}
printf("%ld\n",sum);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator