Cod sursa(job #417537)

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