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:给两组数据吧,测试数据都能过,就是WA啊。

Posted by plich at 2006-11-15 17:13:58 on Problem 1207
In Reply To:给两组数据吧,测试数据都能过,就是WA啊。 Posted by:plich at 2006-11-15 17:11:24
> 希望哪位有耐心的大牛帮看一下
> #include<stdio.h>
> int cycleL(int n)
> {
> 	int c=1;
> 	while(1)
> 	{
> 	if(n==1)
> 		break;
> 	else {
> 		if(n%2==1)
> 			n=3*n+1;
> 		else n=n/2;
> 		c++;
> 	}
> 	}
> 	return c;
> }
> int main(){
> 	int m=1,i,j,c;
> 	while(i!=1||j!=1)
> 	{
> 		scanf("%i%i",&i,&j);
> 		if(i<=j)
> 			for(c=i;c<=j;c++)
> 				m=(cycleL(c)>m)?cycleL(c):m;
> 		else
> 			for(c=j;c<=i;c++)
> 				m=(cycleL(c)>m)?cycleL(c):m;
> 		printf("%i %i %i",i,j,m);
> 		m=1;
> 	}
> 	return 0;
> }

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