当前位置: > 一道ACM题,总是 output limit exceed,谁能告我为什么是这个错误...
题目
一道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

提问时间: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的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.