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

请指点……怎wrong answer?

Posted by qzmc at 2009-07-19 21:28:20 on Problem 1207
#include <stdio.h>

int max(int n, int m)
{
	int i, j, c = 0, add;
	for (j = n; j <= m; j++){
		add = 0;
		for (i = j; i >= 1;){
		if (i == 1){
		   add++;
		   break;
		}
        else if(i % 2 == 0){
            i = i/2;
            add++;
		   }
		else {i = 3 * i + 1;
               add++;
		   }
		}
		if (c < add)
		c = add;
	}
	return c;
}
int main()
{
	int x, y, Max;
	while (scanf ("%d%d", &x, &y) == 2){
		Max = max(x, y);
		printf ("%d %d %d", x, y, Max);
		printf ("\n");
	}
	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