一道ACM题,总是 output limit exceed,谁能告我为什么是这个错误1013:The 3n + 1 problem Time Limit:1 Sec Memory Limit:64 MBSubmit:58 Solved:16[Submit][STATUS][Web Board]DescriptionConsider the following algorithm to generate a sequence of

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/12 01:57:09
一道ACM题,总是 output limit exceed,谁能告我为什么是这个错误1013:The 3n + 1 problem Time Limit:1 Sec Memory Limit:64 MBSubmit:58 Solved:16[Submit][STATUS][Web Board]DescriptionConsider the following algorithm to generate a sequence of
xVmoE+CU"缐q(Q%ćMqת*@Rڢ iAU7 b/0{~IhBm<3yŸW[nMilqo pG6!Z͵xf}^֟rf}ޞ6g&/ăYxG'6D4: 3QAG e⌛sZ6?}/??>)9n[$ yB]˔-.򀊢"a$ BaDM/L|ÆBE={rE^a*/@@b@ RӨ4Let d:q /r݊B{,3.%0*Clڅ2,[n0 <,!/ CB\|dz{NP dR&3ɀi0oH2`p2i00(0L Y" ¸ 2chgץZN:]%7/PYuE:R)Q!e%V(4*Td33V]K"r͓B)OuJ`(ȑK35!)X̾~atdަbU@yU%#0StMQ<2".h(ou-p'9lLK^T͒-ĸH[4Pm?.} SSj+;u 5xց^RHU[vǝ  F)C 7.@IHm5l|EȉF0B ٗ}fx$ѤP1 S#בTķtᒐTeCo928S:Y:d$I}T[҄uv9Oz}ΤM$i ļ,z!̌cHk'GwkݻӻJ搨$+@Yz~].5Jƒ ^V`i][{ugƙ@/Z_NZjϯ`DϐH^>nɉ?\f(yG7N.(>{,@V7VV5_@ j|zC]觓+hJRW჏ﶤ/q v;7C7yy'N5ܾXYQ}zZzaI+NdJks`6Wbŏ׏?i?

一道ACM题,总是 output limit exceed,谁能告我为什么是这个错误1013:The 3n + 1 problem Time Limit:1 Sec Memory Limit:64 MBSubmit:58 Solved:16[Submit][STATUS][Web Board]DescriptionConsider the following algorithm to generate a sequence of
一道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 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.
Output
For each pair of input integers i and j,output i,j in the same order in which they appeared in the input and then the maximum cycle length for integers between and including i and j.These three numbers should be separated by one space,with all three numbers on one line and with one line of output for each line of input.
Sample Input
1 10
100 200
201 210
900 1000
Sample Output
1 10 20
100 200 125
201 210 89
900 1000 174
我的代码:
#include
int main()
{
long i,j,k,s,t,max,m;
while(scanf("%ld%ld",&i,&j))
{
max=0;
for(k=i;kmax)
{
max=s;
}
}
printf("%ld %ld %ld\n",i,j,max);
}
return 0;
}

一道ACM题,总是 output limit exceed,谁能告我为什么是这个错误1013:The 3n + 1 problem Time Limit:1 Sec Memory Limit:64 MBSubmit:58 Solved:16[Submit][STATUS][Web Board]DescriptionConsider the following algorithm to generate a sequence of
#include
int 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,交换他们的位置
max=0;
for(k=i;kmax)
{
max=s;
}
}
printf("%ld\n",max); // 补充最大值
}
return 0;
}

输出超限……一般是没有处理好程序的退出条件
你把 while(scanf("%ld%ld",&i,&j))
改成 while(scanf("%ld%ld",&i,&j)!=EOF)
试一试

一道ACM题,总是 output limit exceed,谁能告我为什么是这个错误1013:The 3n + 1 problem Time Limit:1 Sec Memory Limit:64 MBSubmit:58 Solved:16[Submit][STATUS][Web Board]DescriptionConsider the following algorithm to generate a sequence of acm wrong answer是由什么引起的?北邮一道简单的减法题:北邮一道简单的减法题:DescriptionCalculate A-BInputTwo integer a and b(-10^100 < a,b < 10^100)OutputOutput a-bSample Input1 2Sample Output-1#include using namespace std 一道acm的排序题Snow_storm有n(0 有关ACM算法的一道题,请各位大牛帮帮忙!Problem - A+B for Input-Output DescriptionYour task is to calculate the sum of some integers.InputInput contains multiple test cases, and one case one line. Each case starts with an integer N, and A+B for Input-Output Practice 这是ACM杭大题库的一道题各位大哥大姐们谁知道答案啊?Problem DescriptionYour task is to Calculate a + b.InputInput contains an integer N in the first line,and then N lines follow.Each line consists of 英语翻译The output contains the number of digits in the factorial of the integers appearing in the input.PS:这是一道ACM题中出现的,一个单词一个单词查,最后也木串出一个明确的意思⊙﹏⊙b汗 一道ACM的入门题:A+B for Input-Output Practice1(入门)DescriptionYour task is to Calculate a + b.InputInput contains multiple test cases.Each test case contains a pair of integers a and b,one pair of integers per line.A test case containing 0 一道简单的acm题,可是我老是通不过ojInputInputcontains multiple test cases, and one case one line. Each case starts with aninteger N, and then N integers follow in the same line. OutputFor each testcase you should output the sum of N inte Output 一道极限题(关联三角函数)lim(x—>π/3)(sinx-sinπ/3)/(x-π/3)lim(x—>0)(cosx-1)/x为啥我算这总是无穷大? c语言acm题 acm刷题是什么意思 阶乘所得结果的位数怎么算?这是一道acm编程题. acm的一道c语言问题 一道极限证明题已经lim(an)=a,求证lim(1/an)=1/a 一道简单的ACM题目,快速排序的,老是提交不成功,大家帮我看看DescriptionGive a set of numbers,output them after sort.You may use any algorithm you like to solve it.InputEach input file contains only one case.Each test case begins 一道99年ACM竞赛题Description For each list of words,output a line with each word reversed without changing the order of the words.This problem contains multiple test cases!The first line of a multiple input is an integer N,then a blank line fol acm的一道题贪心的酒鬼我总是wrong answer有没有人能挑战下,代码很短.c语言老李是个酒鬼.可惜他又是一个好吃懒做的人.他身上只有M 元钱,他知道商店啤酒的价格是 K 元钱每瓶,而且 N 个啤酒