#P5968. [POI 2017] Reprezentacje ró?nicowe
[POI 2017] Reprezentacje ró?nicowe
Problem Description
Given a sequence :
- When , .
- When and is odd, .
- When and is even, .
Here, $r_{n-1} = \operatorname{mex}(|a_i - a_j|)(1 \le i \le j \le n - 1)$, and denotes the smallest non-negative integer that is not in the set .
The first several terms of the sequence are:
$1,2,4,8,16,21,42,51,102,112,224,235,470,486,972,990,1980$.
It can be proven that for any positive integer , there exists a unique pair of integers such that , which is defined as .
For example, , and .
Now there are queries. Each query gives a positive integer . For each query, output .
Input Format
The first line contains a positive integer .
The next lines each contain a positive integer , representing a query.
Output Format
Output lines. Each line contains two positive integers , answering each query in order.
2
17
18
6 3
16 15
Hint
For of the testdata, , and .
Translated by ChatGPT 5