欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1323A.Even Subset Sum Problem
Even Subset Sum Problem
You are given an array consisting of positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by ) or determine that there is no such subset.
Both the given array and required subset may contain equal values.
Input
The first line contains a single integer (), number of test cases to solve. Descriptions of test cases follow.
A description of each test case consists of two lines. The first line contains a single integer (), length of array .
The second line contains integers (), elements of . The given array can contain equal values (duplicates).
Output
For each test case output if there is no such subset of elements. Otherwise output positive integer , number of elements in the required subset. Then output distinct integers (), indexes of the chosen elements. If there are multiple solutions output any of them.
Note
There are three test cases in the example.
In the first test case, you can choose the subset consisting of only the second element. Its sum is and it is even.
In the second test case, there is only one non-empty subset of elements consisting of the first element, however sum in it is odd, so there is no solution.
In the third test case, the subset consisting of all array's elements has even sum.
Samples
3
3
1 4 3
1
15
2
3 5
1
2
-1
2
1 2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |