| TheForces Round #28 (Epic-Forces) |
|---|
| Finished |
You are given two integers $$$n$$$ and $$$k$$$.
There's an $$$n\times n$$$ grid. At each step, you can move one cell up, down, left, or right, but you cannot move out of bounds. At first, all cells in the grid are white. You need to color some cells black, such that no matter how you move from the top-left corner to the bottom-right corner, you pass through at least $$$k$$$ number of black cells.
Find the minimum number of black cells required to be colored to satisfy the condition above.
The first line contains a single integer $$$t(1 \le t\le 1000)$$$ — the number of test cases.
The only line of each test case contains two space-separated integers $$$n$$$ and $$$k(2 \le n\le 1000,0\le k\le 2\cdot n-1)$$$.
For each test case, output in a new line — the minimum number of black cells required to be colored to satisfy the condition above.
52 02 16 710 19300 194
0 1 16 100 9506
| Name |
|---|


