Solution in c++
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int main()
{
scanf("%d" ,&n);
if(n==1)
{
cout<<"1\n1 1";
return 0;
}
if(n%2)
{
if(((n-1)/2)%2==0)
{
cout<<"1\n"<<n/2+1<<" 1 ";
for(int i=1;i<=(n-1)/4;i++)cout<<i+1<<" "<<n+1-i<<" ";
}
else
{
cout<<"0\n"<<n/2+1<<" 1 "<<n/2+1<<" ";
for(int i=1;i<=(n-3)/4;i++)cout<<i+1<<" "<<n+1-i<<" ";
}
}
else if(n%2==0 && (n/2)%2==0)
{
cout<<"0\n"<<n/2<<" ";
for(int i=1;i<=n/4;i++)cout<<i<<" "<<n+1-i<<" ";
}
else
{
cout<<"1\n"<<((n-2)/2)+1<<" ";
for(int i=1;i<=(n-2)/4;i++)cout<<i<<" "<<n+1-i<<" ";
cout<<n/2;
}
return 0;
}
0 التعليقات:
إرسال تعليق