Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:wrong answer那位高手帮我看一下,大恩不言谢了

Posted by ft1826119 at 2005-11-21 14:58:28 on Problem 1207
In Reply To:wrong answer那位高手帮我看一下,大恩不言谢了 Posted by:jiabiao at 2005-08-05 21:01:49
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator