A11381 | Dividing the numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Petya has $n$ integers: $1,2,3,...,n$ . He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible.
Help Petya to split the integers. Each of $n$ integers should be exactly in one group.
Help Petya to split the integers. Each of $n$ integers should be exactly in one group.
输入格式
The first line contains a single integer $n$ ( $2<=n<=60000$ ) — the number of integers Petya has.
输出格式
Print the smallest possible absolute difference in the first line.
In the second line print the size of the first group, followed by the integers in that group. You can print these integers in arbitrary order. If there are multiple answers, print any of them.
In the second line print the size of the first group, followed by the integers in that group. You can print these integers in arbitrary order. If there are multiple answers, print any of them.
输入输出样例
输入 #1
4
输出 #1
0 2 1 4
输入 #2
2
输出 #2
1 1 1
In the first example you have to put integers $1$ and $4$ in the first group, and $2$ and $3$ in the second. This way the sum in each group is $5$ , and the absolute difference is $0$ .
In the second example there are only two integers, and since both groups should be non-empty, you have to put one integer in the first group and one in the second. This way the absolute difference of sums of integers in each group is $1$ .
In the second example there are only two integers, and since both groups should be non-empty, you have to put one integer in the first group and one in the second. This way the absolute difference of sums of integers in each group is $1$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted