CF899C.Dividing the numbers
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
佩蒂亚有 n 个整数:1,2,3,…,n。他希望将这些整数划分为两个非空组,使得两组整数之和的绝对差尽可能小。
请帮助佩蒂亚完成这一划分。这 n 个整数中的每一个都必须且仅属于其中一组。
输入格式
The first line contains a single integer n (2 ≤ n ≤ 60 000) — the number of integers Petya has.
第一行包含一个整数 n(2≤n≤60000)—— 表示佩蒂亚拥有的整数个数。
输出格式
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.
在第一行输出最小可能的绝对差值。
在第二行,先输出第一个分组的大小,然后输出该分组中的所有整数。这些整数可以按任意顺序输出。若存在多个满足条件的答案,输出任意一个即可。
输入输出样例
输入#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.
在第一个例子中,你需要将整数 1 和 4 放入第一组,2 和 3 放入第二组。这样每组的和均为 5,两组和的绝对差为 0。
在第二个例子中,仅有两个整数,且由于两组均需非空,你必须将一个整数放入第一组,另一个放入第二组。这样两组整数和的绝对差为 1。
输入解题思路,AI测评打分。不知道怎么写?