欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2156A.Pizza Time
Pizza Time
Hao and Alex are good friends. After winning a coding competition together, they received a huge pizza as their prize.
Initially, they are given slices of pizza. Each day, the following process takes place:
-
If there are at most slices remaining, Alex eats all of them.
-
Otherwise, let be the current number of slices (). Hao splits them into three groups of sizes , , and such that:
$$m_1 + m_2 + m_3 = m\text{ and } 1 \le m_1\le m_2\le m_3.$$</p><p>Then:</p><ul> <li> Hao eats$m\_1$slices (the smallest group). </li><li> Alex eats$m\_2$slices (the middle group). </li><li> The remaining$m\_3$ slices (the largest group) are carried over to the next day.$$
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first and only line of each test case contains a single integer () — the initial number of pizza slices.
Note that there are no constraints on the sum of over all test cases.
Output
For each test case, output a single integer representing the maximum total number of slices Hao can eat.
Note
In the first test case, Hao can eat slices as follows:
- Split into , , and . Hao eats slices, Alex eats slices, and the remaining slices are carried over to the next day.
- Split into , , and . Hao eats slice, Alex eats slice, and the remaining slice is carried over to the next day.
- Only slice remains, so Alex eats it.
In the second test case, Hao can eat slice as follows:
- Split into , , and . Hao eats slice, Alex eats slice, and the remaining slices are carried over to the next day.
- Only slices remain, so Alex eats them all.
Samples
3
8
4
3
3
1
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |