欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1810B.Candies
Candies
This problem is about candy. Initially, you only have candy, and you want to have exactly candies.
You can use the two following spells in any order at most times in total.
- Assume you have candies now. If you use the first spell, then candies become candies.
- Assume you have candies now. If you use the second spell, then candies become candies.
Construct a sequence of spells, such that after using them in order, you will have exactly candies, or determine it's impossible.
Input
Each test contains multiple test cases. The first line contains a single integer () — the number of test cases. Their description follows.
Each test case contains one line with a single integer () — the required final number of candies.
Output
For each test case, output the following.
If it's possible to eventually have candies within spells, in the first line print an integer (), representing the total number of spells you use.
In the second print integers ( is or ) separated by spaces, where means that you use the first spell in the -th step, while means that you use the second spell in the -th step.
Note that you do not have to minimize , and if there are multiple solutions, you may output any one of them.
If it's impossible, output in one line.
Note
For , you can just use the second spell once, and then have candies.
For , you can use the second spell twice. After the first step, you will have candies. And after the second step, you will have candies.
Samples
4
2
3
7
17
-1
1
2
2
2 2
4
2 1 1 1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |