AtCoder Grand Contest 057
翻译中…
Problem Statement
翻译中…
You are given positive integers $S$ and $K$. A sequence of positive integers $A = (A_1, A_2, \ldots, A_N)$ is said to be a good sequence when satisfying the following two conditions.
翻译中…
$1\leq A_1 < A_2 < \cdots < A_N \leq S - 1$holds.$\sum_{i=1}^NA_ix_i\neq S$holds for any sequence of non-negative integers$(x_1, x_2, \ldots, x_N)$.
翻译中…
Let $A = (A_1, A_2, \ldots, A_N)$ be the lexicographically smallest of the good sequences with the maximum number $N$ of terms. Print the $K$-th term $A_K$ of this sequence, or -1 if $K > N$.
翻译中…
We will give you $T$ test cases; solve each of them.
翻译中…
Constraints
翻译中…
$1\leq T\leq 1000$$3\leq S\leq 10^{18}$$1\leq K \leq S - 1$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
T
\text{case}_1
\vdots
\text{case}_T
翻译中…
Each case is in the following format:
翻译中…
S K
翻译中…
Output
翻译中…
Print $T$ lines. The $i$-th line should contain the answer for $\text{case}_i$.
翻译中…
样例
Input #1
13
3 1
3 2
7 1
7 2
7 3
7 4
10 1
10 2
10 3
10 4
10 5
2022 507
1000000000000000000 999999999999999999
Output #1
2
-1
2
4
6
-1
3
6
8
9
-1
1351
-1
For the cases $S = 3, 7, 10$, the sequence $A$ will be as follows.
- For $S=3$: $A = (2)$.
- For $S=7$: $A = (2,4,6)$.
- For $S=10$: $A = (3,6,8,9)$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。