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

帮我这个新手看一下c 下的1207呗

Posted by lawrenceparley at 2008-02-24 19:54:01
#include<stdio.h>
int length(int a)
{
	int n=0;
	while(a!=1)
	{
		if(a%2==0)
			a=a/2;
		else
			a=3*a+1;
		n=n+1;
	}
	return n+1;
}
main()
{
    int i,j,n,a,b;
	scanf("%d%d",&i,&j);
        while(j<=10000)
{
    b=0;a=0;
         for(n=i;n<=j;n++)
	{
		a=length(n);
		if(a>=b)
		b=a;
	}
	printf("%d %d %d\n",i,j,b);
        scanf("%d%d",&i,&j);
}
}
其中while那个括号里我没想好填什么。但是基本上可以输入输出正确,在电脑上编译执行都没事。只是提交上后,出现Output Limit Exceeded.怎么办?

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