Codeforces Round 961 (Div. 2)
A
Diagonals
Codeforces
800
原题
←B1 →
翻译中…

Vitaly503 is given a checkered board with a side of $n$ and $k$ chips. He realized that all these $k$ chips need to be placed on the cells of the board (no more than one chip can be placed on a single cell).

翻译中…

Let's denote the cell in the $i$-th row and $j$-th column as $(i ,j)$. A diagonal is the set of cells for which the value $i + j$ is the same. For example, cells $(3, 1)$, $(2, 2)$, and $(1, 3)$ lie on the same diagonal, but $(1, 2)$ and $(2, 3)$ do not. A diagonal is called occupied if it contains at least one chip.

翻译中…

Determine what is the minimum possible number of occupied diagonals among all placements of $k$ chips.

翻译中…

Input

翻译中…

Each test consists of several sets of input data. The first line contains a single integer $t$ ($1 \le t \le 500$) — the number of sets of input data. Then follow the descriptions of the sets of input data.

翻译中…

The only line of each set of input data contains two integers $n$, $k$ ($1 \le n \le 100, 0 \le k \le n^2$) — the side of the checkered board and the number of available chips, respectively.

翻译中…

Output

翻译中…

For each set of input data, output a single integer — the minimum number of occupied diagonals with at least one chip that he can get after placing all $k$ chips.

翻译中…

Note

翻译中…

In the first test case, there are no chips, so 0 diagonals will be occupied. In the second test case, both chips can be placed on diagonal $(2, 1), (1, 2)$, so the answer is 1. In the third test case, 3 chips can't be placed on one diagonal, but placing them on $(1, 2), (2, 1), (1, 1)$ makes 2 diagonals occupied. In the 7th test case, chips will occupy all 5 diagonals in any valid placing.

翻译中…

样例

Input #1
7
1 0
2 2
2 3
2 4
10 50
100 239
3 9
Output #1
0
1
2
3
6
3
5
InputCopy OutputCopy
题目信息
题号
1995A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。