_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 3+1覓語
/*

螻襴讀 碁企 覿 覓語 1 : 3N+ 1 覓語
----------------------------------------

1. 襯 
2.  伎 襯 3螻 螳 螻
3. 讌企 2襦 , 企 3朱 螻燕 れ 1 
4. 蠏碁 1 蟾讌 覦覲
5.  伎 螳 1  蟾讌 豕 螻襯 蟲 蟆

) 22

22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1  --> 豐 16螻



*/
#include "stdafx.h"
#include <iostream>

using namespace std;

int main(int argc, _TCHAR* argv[])
{
	int i, j, max = 1, max_temp = 1;

	cin >> i >> j;

	if(j < i)
	{
		int temp;
		temp = j;
		j = i;
		i = temp;
	}

	if ( i > 0 && j > 0 && i < 1000000 && j < 1000000)
	{
		for(int loop  = i; loop <= j; loop++)
		{
			int val = loop;

			//cout << val << " : ";

			while(val > 1)
			{
				if(val % 2 == 0)
					val = val / 2;
				else
					val = val * 3 + 1;

				max_temp++;

				//cout << val << ", ";
			}

			if(max_temp > max)
				max = max_temp;

			max_temp = 0;
		}
		
		cout << "\n" << i << " ";
		cout << j << " ";
		cout << max + 1 << endl;
	}
	else
		cout << "ロ  覯 0覲企 螻, 1000000 覲企  ." << endl;

	return 0;
}



蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

蠍 蠍 伎 螳讌 殊 . れる 蠍磯ゼ 伎覲企 蟆伎. るジ 蟆 k 殊企. ( 詞朱 覲 蟲譴)