欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1995A.Diagonals
Diagonals
Vitaly503 is given a checkered board with a side of and chips. He realized that all these 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 -th row and -th column as . A diagonal is the set of cells for which the value is the same. For example, cells , , and lie on the same diagonal, but and 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 chips.
Input
Each test consists of several sets of input data. The first line contains a single integer () — 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 , () — 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 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 , so the answer is 1. In the third test case, 3 chips can't be placed on one diagonal, but placing them on makes 2 diagonals occupied. In the 7th test case, chips will occupy all 5 diagonals in any valid placing.
Samples
7
1 0
2 2
2 3
2 4
10 50
100 239
3 9
0
1
2
3
6
3
5
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |