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~WA~,我实在是没辙了……

Posted by klnhrs at 2007-11-15 15:03:54 on Problem 1207
In Reply To:哪位帮忙看一下,WA~WA~,我实在是没辙了…… Posted by:tangyuanamen at 2007-10-02 21:53:13
> #include <iostream>
> using namespace std;
> 
> int solve(int num1, int num2)
> {
> 	int max = 0;
> 	for( int i = num1; i <= num2; i++)
> 	{
> 	    int j = i;
> 		int print_num = 1;
> 		while( j != 1)
> 		{
> 			if(j%2 != 0)
> 				j = (3*j+1);
> 			else
> 				j /= 2;
> 			print_num++;
> 		}
> 		if(print_num > max)
> 			max = print_num;
> 	}
> 	return max;
> }
> 
> int main(int argc, char*argv[])
> {
> 	int m,n;
> 	while(cin >> m >> n && m && n)
> 	{
> 	    int p = m,q = n;
> 		if( p > q)
> 		{
> 			int temp;
> 			temp = p;
> 			p = q;
> 			q = temp;
> 		}
> 		int max = solve(p,q);
> 		cout << m << " " << n << " " << max << endl;
> 	}
> 		return 0;
> }

我也wa 了n次了,,不知道哪错了

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