Cod sursa(job #110626)

Utilizator damaDamaschin Mihai dama Data 27 noiembrie 2007 08:41:54
Problema Multimi2 Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.11 kb
#include <stdio.h>
#include <math.h>

int first[750001], second[250001];
    
int main()
{
    freopen("multimi2.in", "r", stdin);
    freopen("multimi2.out", "w", stdout);
    

    int i, n, goal;
    
    scanf("%d", &n);
   
   
    
   for(i = n; i >= 4; i -= 4)
   {
         first[++first[0]] = i;
         first[++first[0]] = i - 3;
         second[++second[0]] = i - 2;
         second[++second[0]] = i - 1;
   }
   
   if(n % 4 == 3)
   {
        first[++first[0]] = 3;
        second[++second[0]] = 2;
        second[++second[0]] = 1;
   }
   if(n % 4 == 2)
   {
        first[++first[0]] = 1;
        second[++second[0]] = 2;
   }
   
   if(n % 4 == 1)
   {
        first[++first[0]] = 1;
   }
   
   if(2 * (n * (n + 1)) / 4 == n * (n + 1) / 2)
   {
        printf("0\n");
   }
   else
   {
       printf("1\n");
   }
   printf("%d\n", first[0]);
   for(i = 1; i <= first[0]; ++i)
   {
         printf("%d ", first[i]);
   }
   printf("\n%d\n", second[0]);
   for(i = 1; i <= second[0]; ++i)
   {
         printf("%d ", second[i]);
   }
    
    return 0;
}