A10806 | Vulnerable Kerbals
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given an integer $m$ , and a list of $n$ distinct integers between $0$ and $m-1$ .
You would like to construct a sequence satisfying the properties:
- Each element is an integer between $0$ and $m-1$ , inclusive.
- All prefix products of the sequence modulo $m$ are distinct.
- No prefix product modulo $m$ appears as an element of the input list.
- The length of the sequence is maximized.
Construct any sequence satisfying the properties above.
You would like to construct a sequence satisfying the properties:
- Each element is an integer between $0$ and $m-1$ , inclusive.
- All prefix products of the sequence modulo $m$ are distinct.
- No prefix product modulo $m$ appears as an element of the input list.
- The length of the sequence is maximized.
Construct any sequence satisfying the properties above.
输入格式
The first line of input contains two integers $n$ and $m$ ( $0<=n<m<=200000$ ) — the number of forbidden prefix products and the modulus.
If $n$ is non-zero, the next line of input contains $n$ distinct integers between $0$ and $m-1$ , the forbidden prefix products. If $n$ is zero, this line doesn't exist.
If $n$ is non-zero, the next line of input contains $n$ distinct integers between $0$ and $m-1$ , the forbidden prefix products. If $n$ is zero, this line doesn't exist.
输出格式
On the first line, print the number $k$ , denoting the length of your sequence.
On the second line, print $k$ space separated integers, denoting your sequence.
On the second line, print $k$ space separated integers, denoting your sequence.
输入输出样例
输入 #1
0 5
输出 #1
5 1 2 4 3 0
输入 #2
3 10 2 9 1
输出 #2
6 3 9 2 9 8 0
For the first case, the prefix products of this sequence modulo $m$ are $[1,2,3,4,0]$ .
For the second case, the prefix products of this sequence modulo $m$ are $[3,7,4,6,8,0]$ .
For the second case, the prefix products of this sequence modulo $m$ are $[3,7,4,6,8,0]$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted