Cod sursa(job #110630)

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

using namespace std;

vector<int> first, second;
    
int main()
{
    freopen("multimi2.in", "r", stdin);
    freopen("multimi2.out", "w", stdout);
    

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