UVa 371 Ackermann functions (Water ver.)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.