POJ 1207

暴力 题目简直坑

#include<iostream>

using namespace std;
int main(){
	int x,y,max,count,k;
	while(scanf("%d %d",&x,&y)!=EOF){
		cout<<x<<" "<<y<<" ";
		max=1;
		if(x>y){
			int temp=x;
			x=y;
			y=temp;
		}
		for(int i=x;i<=y;++i){
			k=i;
			count=1;
			while(k!=1){
				++count;
				if(k%2) k=3*k+1;
				else	k/=2;
			}
			if(count>max)
				max=count;
		}
		cout<<max<<endl;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/chailyn_trista/article/details/80965670