Cod sursa(job #417559)
| Utilizator | Data | 14 martie 2010 15:40:09 | |
|---|---|---|---|
| Problema | 12-Perm | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.42 kb |
#include<stdio.h>
const char in[]="12perm.in", out[]="12perm.out";
const int mod = 1048576;
int sol, n , j , last, aux;
int t[]={0, 1, 2, 6, 12};
int main()
{
freopen(in,"r",stdin);
freopen(out,"w",stdout);
scanf("%d", &n);
for(j = 5 ; j <= n ; ++j)
{
aux=t[4];
t[4]=(t[4]+t[2]+2*(j-2))&(mod-1);
t[2]=t[3];t[3]=aux;
}
if(n <= 4)printf("%d\n", t[n]);
else printf("%d\n", t[4]);
return 0;
}
