POJ1207 The 3n+1 problem中英对照翻译与参考解答

该博客主要分析了计算机科学中的一个未解决问题——3n+1问题,讨论了算法的性质,并提供了一个用于确定在给定整数范围内最大循环长度的解决方案。博客涵盖了算法的描述、输入输出格式、示例以及参考代码,旨在解决ACM竞赛中的类似问题。
摘要由CSDN通过智能技术生成

POJ1207 The 3n+1 problem

传送门POJ1207
关键词:水题、模拟

Description

Problems 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.

计算机科学的问题通常被列为属于某一个特定类的问题(如NP、不可解、递归)。这个问题是请你分析算法的一个特性:算法的分类对所有可能的输入是未知的。

Consider the following algorithm:
考虑下述算法:

     input n (输入n)
     print n (打印n)
     if n = 1 then STOP (如果n等于1,则停止)
         if n is odd then   n <-- 3n+1 (如果n是奇数,n=3n+1)
         else   n <-- n/2 (否则n=n/2)
     GOTO 2 (跳转到第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

给出输入“22”,则打印下述数字序列: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.)

人们猜想,对于任何整数的输入值,上述算法将终止(当1被打印时)。尽管这一算法很简单,但还不清楚这一猜想是否是正确的。然而,目前已经验证,对所有的0 < n < 1,000,000的整数,该命题正确。

Given an input n, it is possible to determine the number of numbers printed before the 1 i

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值