欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 以下功能将在 **域名备案 + 支付认证完成**后陆续开放,敬请期待: ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 奇遇币在线充值 ⏳ 微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
ABC422D.D - Least Unbalanced
D - Least Unbalanced
Score : points
Problem Statement
Let be a positive integer. Define the imbalance of a sequence of non-negative integers of length as the non-negative integer value obtained by the following operation:
- Initially, set .
- Perform the following series of operations times:
- Update to , where and denote the maximum and minimum values of sequence , respectively.
- Form a new sequence of half the length by pairing elements from the beginning two by two and arranging their sums. That is, set $A \gets (A\_1 + A\_2, A\_3 + A\_4, \dots, A\_{\vert A \vert - 1} + A\_{\vert A \vert})$.
- The final value of is the imbalance.
For example, when , the imbalance is through the following steps:
- Initially, .
- The first series of operations is as follows:
- Update to .
- Set to .
- The second series of operations is as follows:
- Update to .
- Set to .
- Finally, .
You are given a non-negative integer . Among all sequences of non-negative integers of length with sum , construct a sequence that minimizes the imbalance.
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
$N$ $K$
Output
Let be a sequence with minimum imbalance. Let be the imbalance of . Output a solution in the following format:
$U$
$B_1$ $B_2$ $\dots$ $B_{2^N}$
If there are multiple solutions, any of them will be considered correct.
is a sequence with imbalance , which is the minimum imbalance among sequences satisfying the condition.
Samples
1 11
1
5 6
3 56
0
7 7 7 7 7 7 7 7
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |