Petya has
Help Petya to split the integers. Each of n integers should be exactly in one group.
Input
The first line contains a single integer
Output
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.
Examples
Input
4
Output
0
2 1 4
Input
2
Output
1
1 1
Note
In the first example you have to put integers
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
题目大意
思路
如果
如果
如果
如果
这样的话所有的情况都讨论完了。
代码
#include <cstdio>
const int maxn=60000;
int n;
int main()
{
scanf("%d",&n);
if(n%4==0)
{
printf("0\n%d ",n/2);
for(register int i=1; i<=n/2; i+=2)
{
printf("%d %d ",i,n-i+1);
}
}
else if(n%4==1)
{
printf("1\n%d ",n/2);
for(register int i=2; i<=n/2+1; i+=2)
{
printf("%d %d ",i,n-i+2);
}
}
else if(n%4==2)
{
printf("1\n%d 1 ",n/2);
for(register int i=3; i<=n/2+1; i+=2)
{
printf("%d %d ",i,n-i+3);
}
}
else
{
printf("0\n%d 3 ",n/2);
for(register int i=4; i<=n/2+2; i+=2)
{
printf("%d %d ",i,n-i+4);
}
}
return 0;
}