欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1023B.Pair of Toys
Pair of Toys
Tanechka is shopping in the toy shop. There are exactly toys in the shop for sale, the cost of the -th toy is burles. She wants to choose two toys in such a way that their total cost is burles. How many ways to do that does she have?
Each toy appears in the shop exactly once. Pairs and are considered equal. Pairs , where , are not allowed.
Input
The first line of the input contains two integers , () — the number of toys and the expected total cost of the pair of toys.
Output
Print the number of ways to choose the pair of toys satisfying the condition above. Print 0, if Tanechka can choose no pair of toys in such a way that their total cost is burles.
Note
In the first example Tanechka can choose the pair of toys () or the pair of toys ().
In the second example Tanechka can choose only the pair of toys ().
In the third example choosing any pair of toys will lead to the total cost less than . So the answer is 0.
In the fourth example she can choose the following pairs: , , , ..., . The number of such pairs is exactly .
Samples
8 5
2
8 15
1
7 20
0
1000000000000 1000000000001
500000000000
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |