poj1207
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 50513 | Accepted: 15986 |
Description
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 2
Given 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 before the 1 is printed. 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.
Input
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.
Output
Sample Input
1 10
100 200
201 210
900 1000
Sample Output
1 10 20
100 200 125
201 210 89
900 1000 174
Source
poj1207的更多相关文章
- poj-1207 THE 3n+1 problem
Description Problems in Computer Science are often classified as belonging to a certain class of pro ...
- poj1207 3n+1 problem
The 3n + 1 problem Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 60496 Accepted: 19 ...
- Poj1207 The 3n + 1 problem(水题(数据)+陷阱)
一.Description Problems in Computer Science are often classified as belonging to a certain class of p ...
- ACM训练计划建议(写给本校acmer,欢迎围观和指正)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
- 【POJ水题完成表】
题目 完成情况 poj1000:A+B problem 完成 poj1002:电话上按键对应着数字.现在给n个电话,求排序.相同的归一类 完成 poj1003:求最小的n让1+1/2+1/3+...+ ...
- poj 算法 分类
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 最近AC题:2528 更新时间:2011.09.22 ...
- POJ1008 1013 1207 2105 2499(全部水题)
做了一天水题,挑几个还算凑合的发上来. POJ1008 Maya Calendar 分析: #include <iostream> #include <cstdio> #inc ...
- POJ 水题(刷题)进阶
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- ACM训练计划建议(转)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
随机推荐
- Computer Transformation(hdoj 1041)
Problem Description A sequence consisting of one digit, the number 1 is initially written into a com ...
- 字符排序(hdoj1106)
Problem Description 输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整 ...
- Wcf实现IServiceBehavior拓展机制
IServiceBehavior接口 描述:提供一种在整个服务内修改或插入自定义拓展机制: 命名空间: System.ServiceModel.Description程序集: System.Ser ...
- JS如何设置计算几天前的时间?
计算多少天前的具体时间.比如今天是9月5日,那7天前正常就是8月29了. 之前曾经直接用时间进行加减,吃了大亏,后来脑残到直接写了一个很复杂的计算闰年,闰月,30.31.28的月份 现在分享一下. f ...
- C语言的本质(14)——不完全类型和复杂声明
ISO 将 C 的类型分为三个不同的集合: 函数.对象和不完全类型三大类.函数类型很明显:对象类型包含其他一切,除非不知道对象的大小.该标准使用术语"对象类型"指定指派的对象必须具 ...
- Android 获取系统内置Intent
1,掉web浏览器 Uri myBlogUri = Uri.parse("http://www.yzmanga.com"); returnIt = new Intent(Inten ...
- 【hihocoder1255 Mysterious Antiques in Sackler Museum】构造 枚举
2015北京区域赛现场赛第2题. 题面:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf OJ链接:http://hih ...
- poj 1094 Sorting It All Out_拓扑排序
题意:是否唯一确定顺序,根据情况输出 #include <iostream> #include<cstdio> #include<cstring> #include ...
- C指针
1,每行最大长度,处理的最大列号; preprocessor directives,preprocessor,预处理器读入源代码,根据预处理指令对其进行修改,把修改后 的源代码递交给编译器; 预处理器 ...
- C# 泛型转换 将object[] 数组转换为泛型列表
public List<TaskSoftInfo> ReadSoftDownTaskList() { string[] Tid = (strin ...