欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1447A.Add Candies
Add Candies
There are bags with candies, initially the -th bag contains candies. You want all the bags to contain an equal amount of candies in the end.
To achieve this, you will:
- Choose such that
- Perform operations. In the -th operation, you will pick one bag and add candies to all bags apart from the chosen one.
Your goal is to find a valid sequence of operations after which all the bags will contain an equal amount of candies.
- It can be proved that for the given constraints such a sequence always exists.
- You don't have to minimize .
- If there are several valid sequences, you can output any.
Input
Each test contains multiple test cases.
The first line contains the number of test cases (). Description of the test cases follows.
The first and only line of each test case contains one integer ().
Output
For each testcase, print two lines with your answer.
In the first line print () — the number of operations you want to take.
In the second line print positive integers (), where is the number of bag you chose on the -th operation.
Note
In the first case, adding candy to all bags except of the second one leads to the arrangement with candies.
In the second case, firstly you use first three operations to add candies in total to each bag except of the third one, which gives you . Later, you add candies to second and third bag, so you have , and candies to first and third bag — and the result is .
Samples
2
2
3
1
2
5
3 3 3 1 2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |