U E D R , A S I H C RSS

3 N+1 Problem/조동영

~cpp 
#include <iostream>

using namespace std;


int CheckCount (int low, int high){
	int temp;
	int count = 1;
	int maxCount = 0;
	temp = low;
	while(temp<high){
		count = 1;
		while(temp !=1){
			if(temp % 2 == 1)
				temp = 3 * temp + 1;
			else
				temp = temp / 2;
			count++;
		}
		temp = ++low;
		if(count > maxCount)
			maxCount = count;
	}
	return maxCount;
}

void main(){
	cout << "2       함" << endl;
	int num1, num2;
	cin >> num1 >> num2;
	
	cout << "MAX cycle-length " << CheckCount(num1,num2) << "." << endl;
}

함 해
ㅠㅠ ... 하 ... .. 1 1000000 ...
흔히 . . ㅋ --


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:16
Processing time 0.0101 sec