371-ackermann functions
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=307
An Ackermann function has the characteristic this length of the sequence of numbers generated by the function cannot b E computed directly from the input value. One particular integer Ackermann function is the following:
This Ackermann has the characteristic is it eventually converges on 1. A few examples follow in which the starting value is shown to square brackets followed by the sequence of values that are Generated, followed by the length of the sequence in curly braces:
[5] 8 4 2 1 {6} [5 8 4 2 1
{9}
[] 7 5
[8 4 2/1} [+] [+] 9] 58 29 88 44 22 ... 2 1 {}
[8] 4 2 1 {5}
[1] 4 2 1 {3}
Input and Output
Your program are to read in a series of pairs of values, that represent the "I" and last numbers in a closed sequence. For each closed sequence pair determine which value generates the longest series of values before it converges to 1. The largest value in the sequence won't be larger than can is accomodated in a 32-bit Pascal longint or C long. The last pair of values would be 0, 0. The output from your program should is as follows:
Betweenlandh, vgenerates the longest sequence ofsvalues.
Where:
L = The lower boundary value in the sequence
H = The upper boundary value in the sequence
V = The ' the ' generates ' longest sequence, (if two or more values generate the longest sequence-only sh ow the lower value S = The length of the generated sequence.
In the event so two numbers in the interval should both produce equally long sequences.
Sample Input
1
0 0
Sample Output
Between 1 and generates the longest sequence of values.
Between generates the longest sequence of 112 values.
The same question.