A9428 | Toy Sum
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris.
There are exactly $s$ blocks in Chris's set, each block has a unique number from 1 to $s$ . Chris's teacher picks a subset of blocks $X$ and keeps it to himself. He will give them back only if Chris can pick such a non-empty subset $Y$ from the remaining blocks, that the equality holds:
 "Are you kidding me?", asks Chris.For example, consider a case where $s=8$ and Chris's teacher took the blocks with numbers 1, 4 and 5. One way for Chris to choose a set is to pick the blocks with numbers 3 and 6, see figure. Then the required sums would be equal: $(1-1)+(4-1)+(5-1)=(8-3)+(8-6)=7$ .
However, now Chris has exactly $s=10^{6}$ blocks. Given the set $X$ of blocks his teacher chooses, help Chris to find the required set $Y$ !
There are exactly $s$ blocks in Chris's set, each block has a unique number from 1 to $s$ . Chris's teacher picks a subset of blocks $X$ and keeps it to himself. He will give them back only if Chris can pick such a non-empty subset $Y$ from the remaining blocks, that the equality holds:
 "Are you kidding me?", asks Chris.For example, consider a case where $s=8$ and Chris's teacher took the blocks with numbers 1, 4 and 5. One way for Chris to choose a set is to pick the blocks with numbers 3 and 6, see figure. Then the required sums would be equal: $(1-1)+(4-1)+(5-1)=(8-3)+(8-6)=7$ .
However, now Chris has exactly $s=10^{6}$ blocks. Given the set $X$ of blocks his teacher chooses, help Chris to find the required set $Y$ !
输入格式
The first line of input contains a single integer $n$ ( $1<=n<=5·10^{5}$ ), the number of blocks in the set $X$ . The next line contains $n$ distinct space-separated integers $x_{1}$ , $x_{2}$ , $...$ , $x_{n}$ ( $1<=x_{i}<=10^{6}$ ), the numbers of the blocks in $X$ .
Note: since the size of the input and output could be very large, don't use slow output techniques in your language. For example, do not use input and output streams (cin, cout) in C++.
Note: since the size of the input and output could be very large, don't use slow output techniques in your language. For example, do not use input and output streams (cin, cout) in C++.
输出格式
In the first line of output print a single integer $m$ ( $1<=m<=10^{6}-n$ ), the number of blocks in the set $Y$ . In the next line output $m$ distinct space-separated integers $y_{1}$ , $y_{2}$ , $...$ , $y_{m}$ ( $1<=y_{i}<=10^{6}$ ), such that the required equality holds. The sets $X$ and $Y$ should not intersect, i.e. $x_{i}≠y_{j}$ for all $i$ , $j$ ( $1<=i<=n$ ; $1<=j<=m$ ). It is guaranteed that at least one solution always exists. If there are multiple solutions, output any of them.
输入输出样例
输入 #1
3 1 4 5
输出 #1
2 999993 1000000
输入 #2
1 1
输出 #2
1 1000000
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted