Cod sursa(job #206451)

Utilizator rapidu36Victor Manz rapidu36 Data 6 septembrie 2008 19:23:01
Problema Multimi2 Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 1.07 kb

#include<stdio.h>

void rest0(int n){
	int i,j;
	printf("0\n%d\n",n/2);
	for(i=1,j=n;i<=n/4;++i,--j)
		printf("%d %d ",i,j);
	printf("\n%d\n",n/2);
	for(;i<j;++i,--j)
		printf("%d %d ",i,j);
	printf("\n");
}

void rest1(int n){
	int i,j;
	printf("1\n%d\n1 ",n/2+1);
	for(i=2,j=n;i<=n/4+1;++i,--j)
		printf("%d %d ",i,j);
	printf("\n%d\n",n/2);
	for(;i<=j;++i,--j)
		printf("%d %d ",i,j);
	printf("\n");
}

void rest2(int n){
	int i,j;
	printf("1\n%d\n%d ",n/2,n);
	for(i=1,j=n-2;i<=n/4;++i,--j)
		printf("%d %d ",i,j);
	printf("\n%d\n%d ",n/2,n-1);
	for(;i<=j;++i,--j)
		printf("%d %d ",i,j);
	printf("\n");
}

void rest3(int n){
	int i,j;
	printf("0\n%d\n",n/2+1);
	for(i=1,j=n-1;i<=(n+1)/4;++i,--j)
		printf("%d %d ",i,j);
	printf("\n%d\n",n/2);
	for(;i<j;++i,--j)
		printf("%d %d ",i,j);
	printf("%d\n",n);
}

int main(){
	freopen("multimi2.in","r",stdin);
	freopen("multimi2.out","w",stdout);
	int n;
	scanf("%d",&n);
	if(n%4==0)
		rest0(n);
	if(n%4==1)
		rest1(n);
	if(n%4==2)
		rest2(n);
	if(n%4==3)
		rest3(n);
	return 0;
}