Pagini recente » Cod sursa (job #3286926) | Cod sursa (job #2871912) | Cod sursa (job #2609679) | Cod sursa (job #2370850) | Cod sursa (job #46577)
Cod sursa(job #46577)
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define modul 1 << 20
int main()
{
freopen("12perm.in","r",stdin);
freopen("12perm.out","w",stdout);
int one, two, three, n, i, temp;
one = 2;
two = 6;
three = 12;
scanf("%d", &n);
if(n == 1)
{
printf("1\n");
return 0;
}
if(n == 2)
{
printf("2\n");
return 0;
}
if(n == 3)
{
printf("6\n");
return 0;
}
if(n == 4)
{
printf("12\n");
return 0;
}
for(i = 5; i <= n; ++i)
{
temp = (one + three + 2 * (i - 2));
temp %= modul;
one = two;
two = three;
three = temp;
}
printf("%d\n", three);
return 0;
}