亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

hdu 1032 The 3n + 1 problem

2019-11-11 07:43:20
字體:
來源:轉載
供稿:網友

The 3n + 1 PRoblem

Time Limit: 2000/1000 MS (java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 37180    Accepted Submission(s): 13554Problem DescriptionProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs.Consider the following algorithm:     1.      input n    2.      print n    3.      if n = 1 then STOP    4.           if n is odd then n <- 3n + 1    5.           else n <- n / 2    6.      GOTO 2Given the input 22, the following sequence of numbers will be printed 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 It is conjectured that the algorithm above will terminate (when a 1 is printed) for any integral input value. Despite the simplicity of the algorithm, it is unknown whether this conjecture is true. It has been verified, however, for all integers n such that 0 < n < 1,000,000 (and, in fact, for many more numbers than this.) Given an input n, it is possible to determine the number of numbers printed (including the 1). For a given n this is called the cycle-length of n. In the example above, the cycle length of 22 is 16. For any two numbers i and j you are to determine the maximum cycle length over all numbers between i and j.  InputThe input will consist of a series of pairs of integers i and j, one pair of integers per line. All integers will be less than 1,000,000 and greater than 0. You should process all pairs of integers and for each pair determine the maximum cycle length over all integers between and including i and j. You can assume that no opperation overflows a 32-bit integer. OutputFor each pair of input integers i and j you should output i, j, and the maximum cycle length for integers between and including i and j. These three numbers should be separated by at least one space with all three numbers on one line and with one line of output for each line of input. The integers i and j must appear in the output in the same order in which they appeared in the input and should be followed by the maximum cycle length (on the same line).  Sample Input
1 10100 200201 210900 1000 Sample Output
1 10 20100 200 125201 210 89900 1000 174
#include<iostream>using namespace std;int main(){	int a1,b1,i;	while(cin>>a1>>b1)	{	   int a=a1,b=b1;	   if(a1>b1) {	   a=b1;b=a1;}	   int max=-1,sum,n;	   for(i=a;i<=b;i++)	   {	   	    n=i;	   	    sum=1;			while(n!=1)			{				if(n%2!=0) 				  n=3*n+1;				else				  n=n/2;			 sum++;			}				   if(max<sum) max=sum;		   //cout<<max<<" ";	  }	  cout<<a1<<" "<<b1<<" "<<max<<endl;	}	}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
久久免费视频网站| 日韩中文字在线| 亚洲欧美中文日韩v在线观看| 91国产高清在线| 亚洲一区二区三| 精品久久香蕉国产线看观看亚洲| 亚洲色图色老头| 蜜臀久久99精品久久久无需会员| 亚洲人成绝费网站色www| 色偷偷av一区二区三区| www.欧美三级电影.com| 日韩专区在线播放| 国产精品一区二区女厕厕| 日韩精品福利网站| 成人欧美一区二区三区黑人孕妇| 国产精品久久久久久影视| 精品久久久久久中文字幕| 精品亚洲va在线va天堂资源站| 亚洲免费伊人电影在线观看av| 精品香蕉在线观看视频一| 久久国产精品影视| 92福利视频午夜1000合集在线观看| 亚洲精品国产电影| 亚洲性av网站| 精品国产一区二区三区在线观看| 亚洲电影免费观看高清完整版| 国产精品第8页| 社区色欧美激情 | 国产欧美在线播放| 日韩av色在线| 亚洲va国产va天堂va久久| 欧美精品videos性欧美| 成人黄在线观看| 欧美视频不卡中文| 少妇高潮久久77777| 一本色道久久综合狠狠躁篇的优点| 国产精品香蕉av| 欧美性xxxxx| 日韩欧美国产一区二区| 欧美极度另类性三渗透| 2019中文字幕免费视频| 久久精品视频网站| 亚洲色图av在线| 亚洲国产欧美精品| 亚洲91精品在线| 国产99视频在线观看| 欧美日韩精品中文字幕| 国精产品一区一区三区有限在线| 国产精品久久久久久久久久久久久久| 日韩成人久久久| 亚洲国产日韩欧美在线图片| 91在线中文字幕| 亚洲日韩欧美视频| 狠狠干狠狠久久| 日韩www在线| 中文字幕精品一区二区精品| 国内精品一区二区三区四区| 九色91av视频| 91成人在线视频| 国产精品视频在线观看| 91九色精品视频| 亚洲精品mp4| 国产精品成人一区二区三区吃奶| 欧美成人黄色小视频| 国产精品对白刺激| 国产精品久久久久av| 久久久91精品国产一区不卡| 精品久久久精品| 日韩欧美在线中文字幕| 中文字幕欧美精品在线| 亚洲精品久久久久久久久| 欧美成人网在线| 国产成人一区二区| 国产国语videosex另类| 亚洲视频在线观看免费| 欧美日韩国产精品一区| www.99久久热国产日韩欧美.com| 日韩一区二区欧美| 4438全国亚洲精品在线观看视频| 一本色道久久88亚洲综合88| 国产一区二区美女视频| 亚洲视频999| 国产日韩在线免费| 一区二区三区www| 欧美一区视频在线| 最近2019年日本中文免费字幕| 亚洲国产精品成人精品| 精品久久久久久国产| www.久久撸.com| 国产精品成人一区| 日韩高清电影免费观看完整| 久久久精品中文字幕| 色悠悠国产精品| 久久99国产精品自在自在app| 国产精品国模在线| 成人在线中文字幕| 福利精品视频在线| 成人久久精品视频| 欧美另类69精品久久久久9999| 高清一区二区三区日本久| 久久精视频免费在线久久完整在线看| 91精品综合视频| 日韩中文在线观看| 欧美成人精品xxx| 亚洲成avwww人| 欧美性色视频在线| 91精品视频免费看| 亚洲影院色在线观看免费| 一本色道久久88精品综合| 国产精品视频在线观看| 国产精欧美一区二区三区| 国产精品亚洲片夜色在线| 日本一区二三区好的精华液| 国产高清视频一区三区| 欧美肥臀大乳一区二区免费视频| 91麻豆国产精品| 久久久日本电影| 久久久精品网站| 欧美性猛交xxxx富婆| 欧美另类高清videos| 亚洲精品中文字幕有码专区| 亚洲最新av在线| 国产日韩在线精品av| 国产在线98福利播放视频| 日本视频久久久| 日韩精品高清在线观看| 亚洲无限乱码一二三四麻| 久久精品国产2020观看福利| 亚洲图片制服诱惑| 欧美综合在线第二页| 自拍偷拍亚洲一区| 97av视频在线| 91久久精品国产91性色| 日韩高清av一区二区三区| 国产精品精品一区二区三区午夜版| 中文字幕av一区二区三区谷原希美| 国产盗摄xxxx视频xxx69| 成人伊人精品色xxxx视频| 久久久久久国产精品三级玉女聊斋| 日本精品久久中文字幕佐佐木| 国产精品第3页| 欧美亚洲成人免费| 韩剧1988免费观看全集| 亚洲国产精品久久久久久| 欧美日韩美女视频| 日韩久久精品成人| 欧美大片在线免费观看| 国产欧美日韩中文| 国产一区二区在线免费| 欧美理论电影在线播放| 亚洲激情在线视频| 国产精品久久久久aaaa九色| 国产精品欧美一区二区| 亚洲精品久久久一区二区三区| 91精品中国老女人| 国产亚洲精品美女久久久| 欧美激情一区二区三区久久久| 色婷婷综合久久久久| 欧美高清理论片| 日韩av中文字幕在线免费观看| 亚洲精品视频中文字幕| 91精品国产自产在线观看永久| 成人网中文字幕| 深夜精品寂寞黄网站在线观看|