题目
一道ACM题,总是 output limit exceed,谁能告我为什么是这个错误
1013:The 3n + 1 problem
Time Limit:1 Sec Memory Limit:64 MB
Submit:58 Solved:16
[Submit][STATUS][Web Board]
Description
Consider the following algorithm to generate a sequence of numbers.Start with an integer n.If n is even,divide by 2.If n is odd,multiply by 3 and add 1.Repeat this process with the new value of n,terminating when n = 1.For example,the following sequence of numbers will be generated for n = 22:22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 It is conjectured (but not yet proven) that this algorithm will terminate at n = 1 for every integer n.Still,the conjecture holds for all integers up to at least 1,000,000.For an input n,the cycle-length of n is the number of numbers generated up to and including the 1.In the example above,the cycle length of 22 is 16.Given any two numbers i and j,you are to determine the maximum cycle length over all numbers between i and j,including both endpoints.
Input
The in
1013:The 3n + 1 problem
Time Limit:1 Sec Memory Limit:64 MB
Submit:58 Solved:16
[Submit][STATUS][Web Board]
Description
Consider the following algorithm to generate a sequence of numbers.Start with an integer n.If n is even,divide by 2.If n is odd,multiply by 3 and add 1.Repeat this process with the new value of n,terminating when n = 1.For example,the following sequence of numbers will be generated for n = 22:22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 It is conjectured (but not yet proven) that this algorithm will terminate at n = 1 for every integer n.Still,the conjecture holds for all integers up to at least 1,000,000.For an input n,the cycle-length of n is the number of numbers generated up to and including the 1.In the example above,the cycle length of 22 is 16.Given any two numbers i and j,you are to determine the maximum cycle length over all numbers between i and j,including both endpoints.
Input
The in
提问时间:2021-01-03
答案
#includeint main(){long i,j,k,s,t,max,m;while(scanf("%ld%ld",&i,&j)==2) // 防止Output Limit Exceed{printf("%ld %ld ",i,j); // 先把 i 和 j 输出if(i>j){max = i;i=j;j=max;} // 如果 i 大于 j,交换他们的位...
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1求f(x)=x2-2ax-1在区间[0,2]上的最大值和最小值.
- 2二苯甲烷二异氰酸酯是危险化学品吗?
- 3如图是一种电梯结构的示意图,电梯厢在电梯井中沿,竖直通道上下运行.钢链的两端分别固定在电梯井顶部的一点和B点,刚时钢链绕过重15000N电梯厢下的滑轮而托起整个厢体E,又跨过电
- 4已知a减2的绝对值加括号b加一括号的平方等于零,求括号负a减b括号的二千零十一次方加括号负一的二千零
- 5英语翻译
- 6After the ____exam,the students _____a two month holiday soon.
- 7定语 状语 它在句子中怎样使用?
- 8帮忙啊!though的用法
- 9There will be no work----.A.left undone B.to be left done C.left undoing
- 101.碳1—碳10的烷烃分子式名称
热门考点
- 1一杯500g,20摄氏度的冷水与一杯300克的80摄氏度的热水混合后的温度是多少?
- 2ATP彻底水解耗几个水
- 3三个植树队共植树1700棵,甲队棵数是乙队的三倍,乙队比丙队植树的少植200棵.三个队各植树多少棵?
- 4五年级语文上册上册说明方法有哪些
- 5有理数加法计算题
- 6水果超市出售三种水果,它们占总水果数的百分比如下表,已知桔子比梨多买25箱.算算卖了苹果有多少箱?
- 7如何把对数螺线的极坐标形式转化为直角坐标形式
- 8求:上面一个秃宝盖下面一个山是什么字
- 9him是不是himself的翻身代词
- 10一个圆柱形容器,底面半径20厘米,里面盛有80厘米深的水,现将一个底面直径20厘米的圆锥形铁块完全沉于容器中,水面比原来上升了十六分之一.圆锥形铁块的高是多少厘米.(算式写清除!)