欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1260A.Heating
Heating
Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.
Your house has rooms. In the -th room you can install at most heating radiators. Each radiator can have several sections, but the cost of the radiator with sections is equal to burles.
Since rooms can have different sizes, you calculated that you need at least sections in total in the -th room.
For each room calculate the minimum cost to install at most radiators with total number of sections not less than .
Input
The first line contains single integer () — the number of rooms.
Each of the next lines contains the description of some room. The -th line contains two integers and () — the maximum number of radiators and the minimum total number of sections in the -th room, respectively.
Output
For each room print one integer — the minimum possible cost to install at most radiators with total number of sections not less than .
Note
In the first room, you can install only one radiator, so it's optimal to use the radiator with sections. The cost of the radiator is equal to .
In the second room, you can install up to radiators, but since you need only one section in total, it's optimal to buy one radiator with one section.
In the third room, there variants to install radiators: , , , , , , . The optimal variant is and it costs .
Samples
4
1 10000
10000 1
2 6
4 6
100000000
1
18
10
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |