Вы находитесь на странице: 1из 4
Maratón Interuniversitaria de Programación del Nororiente Colombiano Universidad de Santander – UDES Bucaramanga,
Maratón Interuniversitaria de Programación del Nororiente Colombiano Universidad de Santander – UDES Bucaramanga,
Maratón Interuniversitaria de Programación del Nororiente Colombiano Universidad de Santander – UDES Bucaramanga,

Maratón Interuniversitaria de Programación del Nororiente Colombiano Universidad de Santander UDES Bucaramanga, Agosto 24 de 2011

Problem #1. Training.

Problem Triangle You enter the number of rows in the triangle as the input. The output should be a straight triangle in each row to generate a sequence of numbers from one (1) until the row number that correspond (n) increasing one by one.

Input

3

6

Output

1

12

123

1

12

123

1234

12345

123456

Problem #2

Problem Array This exercise gets an n-dimensional array (assuming a pair dimension), and make an inversion of array data by dividing the array in half and making a new array with the inversion of the two halves. The new array should be composed in the first half by the inversion of the data of that half from the original array and in the second half exchange only the ends.

A vector of the form A1, A2, A3, A4, B1, B2, B3, B4; Give an output vector A4, A3, A2, A1, B1, B3, B2, B4.

Input

6 // This data refers to the dimension of the vector

1

2

3

4

5

6

Output The dimension of the vector is 6; Original vector:

[1] [2] [3] [4] [5] [6] Vector after the inversion is:

[3] [2] [1] [6] [5] [4]

Problem #3

Problem Polynomial

This exercise finds the value of a polynomial whose data are entered into an n-dimensional vector (a vector is assumed pair).

into an n-dimensional vector (a vector is assumed pair). Input 4 // This data corresponds to

Input

4

// This data corresponds to the dimension of the vector

2

// This data is the value of x

1

2

3

4

Output The dimension of the vector is: 4 The value of (x) is: 2 VECTOR: [1] [2] [3] [4]

X equals to: 52

Problem #4

Problem JJ: Jolly Jumpers

A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1. For instance,

1 4 2 3 is a jolly jumper, because the absolutes differences are 3, 2, and 1 respectively. The

definition implies that any sequence of a single integer is a jolly jumper. You are to write a

program to determine whether or not each of a number of sequences is a jolly jumper.

Input Each line of input contains an integer n <= 3000 followed by n integers representing the sequence.

Output For each line of input, generate a line of output saying "Jolly" or "Not jolly".

Sample Input

4 1 4 2 3

5 1 4 2 -1 6

Sample Output

Jolly

Not jolly

Problem #5

Problem ExtraTabl:

Extrapolation Using a Difference Table

A very old technique for extrapolating a sequence of values is based on the use of a difference table. The difference table used in the extrapolation of a sequence of 4 values, say 3, 6, 10, and 15, might be displayed as follows:

values, say 3, 6, 10, and 15, might be displayed as follows: The original sequence of

The original sequence of values appears in the first column of the table. Each entry in the second column of the table is formed by computing the difference between the adjacent entries in the first column. These values (in the second column) are called first differences. Each entry in the third column is similarly the difference between the adjacent entries in the second column; the third column entries are naturally called second differences. Computation of the last column in this example should now be obvious (but beware that this value is not always zero). Note that the last column will always contain only a single value. If we begin with a sequence of n values, the completed difference table will have n columns, with the single value in column n representing the single n-1st difference. To extrapolate using a difference table we assume the n-1st differences are constant (since we have no additional information to refute that assumption). Given that assumption, we can compute the next entry in the n-2nd difference column, the n-3rd difference column, and so forth until we compute the next entry in the first column which, of course, is the next value in the sequence. The table below shows the four additional entries (in boxes) added to the table to compute the next entry in the example sequence, which in this case is 21. We could obviously continue this extrapolation process as far as desired by adding additional entries to the columns using the assumption that the n-1st differences are constant.

Input and Output The input for this problem will be a set of extrapolation requests.

Input and Output The input for this problem will be a set of extrapolation requests. For each request the input will contain first an integer n, which specifies the number of values in the sequence to be extended. When n is zero your program should terminate. If n is non-zero (it will never be larger than 10), it will be followed by n integers representing the given elements in the sequence. The last item in the input for each extrapolation request is k, the number of extrapolation operations to perform; it will always be at least 1. In effect, you are to add k entries to each column of the difference table, finally reporting the last value of the sequence computed by such extrapolation. More precisely, assume the first n entries (the given values) in the sequence are numbered 1 through n. Your program is to determine the n+kth value in the sequence by extrapolation of the original sequence k times.

Hint: no upper limit is given for k, and you might not be able to acquire enough memory to construct a complete difference table.

Sample Input

4

3 6 10 15 1

4

3 6 10 15 2

3

2 4 6 20

6

3 9 12 5 18 -4 10

0

Sample Output Term 5 of the sequence is 21 Term 6 of the sequence is 28 Term 23 of the sequence is 46 Term 16 of the sequence is -319268