欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1862B.Sequence Game
Sequence Game
Tema and Vika are playing the following game.
First, Vika comes up with a sequence of positive integers of length and writes it down on a piece of paper. Then she takes a new piece of paper and writes down the sequence according to the following rule:
- First, she writes down .
- Then, she writes down only those () such that . Let the length of this sequence be denoted as .
For example, from the sequence , Vika will obtain the sequence .
She then gives the piece of paper with the sequence to Tema. He, in turn, tries to guess the sequence .
Tema considers winning in such a game highly unlikely, but still wants to find at least one sequence that could have been originally chosen by Vika. Help him and output any such sequence.
Note that the length of the sequence you output should not exceed the input sequence length by more than two times.
Input
Each test consists of multiple test cases. The first line of input data contains a single integer () — the number of test cases. This is followed by a description of the test cases.
The first line of each test case contains a single integer () — the length of the sequence .
The second line of each test case contains integers () — the elements of the sequence.
The sum of the values of over all test cases does not exceed .
Output
For each test case, output two lines. In the first line, output a single integer — the length of the sequence (). In the second line, output integers () — the assumed sequence that Vika could have written on the first piece of paper.
If there are multiple suitable sequences, you can output any of them.
Note
The first sample is explained in the problem statement.
In the second sample, Vika could have chosen the original sequence.
Samples
6
3
4 6 3
3
1 2 3
5
1 7 9 5 7
1
144
2
1 1
5
1 2 2 1 1
6
4 3 2 6 3 3
3
1 2 3
6
1 7 9 3 5 7
1
144
2
1 1
6
1 2 2 1 1 1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |