#P11156. Sequence Reconstruction
Sequence Reconstruction
Sequence Reconstruction
Given a sequence of positive integers (a_1, a_2, \ldots, a_n) satisfying the recurrence
[ a_i = \lceil \frac{a_{i-2}}{a_{i-1}} \rceil \quad \text{for } i \ge 3, ]
and the bounds
[ 1 \le a_i \le 10^9, \quad \text{for all } 1 \le i \le n, ]
you are provided with two integers: (n) and (a_n) (the last term of the sequence). Your task is to find any valid pair (a_1, a_2) which generates a sequence satisfying the above conditions such that the (n)th term is exactly (a_n).
Note: The ceiling function (\lceil x \rceil) returns the smallest integer not less than (x). For example, (\lceil 7/3 \rceil = 3) and (\lceil 4 \rceil = 4).
inputFormat
The input consists of a single line containing two space-separated integers, (n) and (a_n).
In the sequence (a_1, a_2, \ldots, a_n), if (n \ge 3) the recurrence formula
(a_i = \lceil \frac{a_{i-2}}{a_{i-1}} \rceil) for (i \ge 3)
applies. For (n = 1) or (n = 2), the recurrence does not come into play and any valid pair (a_1, a_2) satisfying the bounds is acceptable.
outputFormat
Output two space-separated integers (a_1) and (a_2) that can generate a sequence fulfilling the conditions such that the (n)th term is (a_n).
sample
3 5
5 1