A8674 | Numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You have a sequence of $n$ distinct integers $a_{1},a_{2},...,a_{n}$ $(1<=a_{i}<=n)$ . You want to remove some integers in such a way that the resulting sequence of integers satisfies the following three conditions:
1. the resulting sequence is not empty;
2. the exclusive or ( $xor$ operation) of all the integers in the resulting sequence equals $0$ ;
3. if you write all the integers of the resulting sequence (from beginning to the end) in a row in the decimal numeral system and without any spaces, the written number is divisible by $p$ .
You are given the sequence of $n$ integers $a$ and a prime number $p$ , find a way to satisfy the described conditions.
1. the resulting sequence is not empty;
2. the exclusive or ( $xor$ operation) of all the integers in the resulting sequence equals $0$ ;
3. if you write all the integers of the resulting sequence (from beginning to the end) in a row in the decimal numeral system and without any spaces, the written number is divisible by $p$ .
You are given the sequence of $n$ integers $a$ and a prime number $p$ , find a way to satisfy the described conditions.
输入格式
The first line of the input contains two integers $n$ and $p$ $(1<=n,p<=50000)$ . Next line contains $n$ space-separated distinct integers $a_{1},a_{2},...,a_{n}$ $(1<=a_{i}<=n)$ .
It is guaranteed that $p$ is a prime number.
It is guaranteed that $p$ is a prime number.
输出格式
If there is no solution for the given input, print "No" (without quotes) in the only line of the output.
Otherwise print "Yes" in the first line of output. The second line should contain an integer $k$ $(k>0)$ specifying the number of remaining elements and the third line should contain $k$ distinct integers $x_{1},x_{2},...,x_{k}$ $(1<=x_{i}<=n)$ . These integers mean that you should remove all integers from the sequence except integers $a_{x1},a_{x2},...,a_{xk}$ to satisfy the described conditions.
If there are multiple solutions, any of them will be accepted.
Otherwise print "Yes" in the first line of output. The second line should contain an integer $k$ $(k>0)$ specifying the number of remaining elements and the third line should contain $k$ distinct integers $x_{1},x_{2},...,x_{k}$ $(1<=x_{i}<=n)$ . These integers mean that you should remove all integers from the sequence except integers $a_{x1},a_{x2},...,a_{xk}$ to satisfy the described conditions.
If there are multiple solutions, any of them will be accepted.
输入输出样例
输入 #1
3 3 1 2 3
输出 #1
Yes 3 1 2 3
输入 #2
3 5 1 2 3
输出 #2
No
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted