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

请教师兄:为什么总是out put exeed啊?

Posted by 19860825 at 2004-12-22 14:18:31 on Problem 1207
#include<stdio.h>
int cycle(int m){
	int count=1;
	while(m!=1){
		count=count+1;
		if(m%2==1) m=3*m+1;
		else m=m/2;
	}
	return count;
}
int main(){
	int i,j,a[10000],max,k,e,d,q;
	scanf("%d %d",&i,&j);
	while(i>0&&j<=10000){
		d=j-i;
		q=i;
	    for(k=0;k<=d+1;k++){
			a[k]=cycle(i);
			i=i+1;
		}
		max=a[0];
		for(k=0;k<=d+1;k++){
			if(max<=a[k+1]) max=a[k+1];
		}
		printf("%d %d %d\n",q,j,max);
		scanf("%d %d",&i,&j);
	}
	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