| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 512 MB | 63 | 23 | 17 | 45.946% |
You are given an array of integers $a_1,\dots,a_n$. Find two indices $i$ and $j$ such that $i<j,ドル $a_i<a_j,ドル and the product $a_i \cdot a_j$ is as small as possible.
The input consists of several tests. The first line contains a single integer $t$ --- the number of tests (1ドル \leq t \leq 10^4$). Each of the following $t$ lines describes one test.
Each test is generated using the following algorithm. The test is described by integers $n,ドル $l,ドル $r,ドル $x,ドル $y,ドル $z,ドル $b_1,ドル $b_2$ (2ドル \leq n \leq 10^7,ドル $-2\cdot10^9 \leq l \leq r \leq 2\cdot10^9,ドル 0ドル \leq x,y,z,b_1,b_2 < 2^{32}$), where $n$ is the length of the array.
First, the sequence $b_i$ of length $n$ is generated. Elements $b_1$ and $b_2$ are given. For $i>2$ let $b_i=(b_{i-2}x+b_{i-1}y+z) \bmod 2^{32}$. For each $i$ between 1ドル$ and $n,ドル $a_i=(b_i \bmod (r - l + 1)) + l$ (thus, $-2\cdot10^9 \leq a_i \leq 2\cdot10^9$).
It is recommended to use 64-bit integers to generate the sequence to avoid integer overflow.
The sum of $n$ in all tests does not exceed 2ドル \cdot 10^7$.
For each test, print the smallest possible product $a_i \cdot a_j$ in a separate line. If there are no such $i$ and $j$ that $i<j$ and $a_i<a_j,ドル print "IMPOSSIBLE".
2 4 -5 5 11 13 17 0 3 5 0 100 0 1 0 42 42
-15 IMPOSSIBLE
Let us consider the generation of the array in the first test.
First, the sequence $b$ is generated.
Then it is used to generate $a$.
Thus, $a = [-5,-2,-4,3]$. The answer is $-5 \cdot 3=-15$.
In the second test the array is $[42,42,42,42,42]$.