Cod sursa(job #417545)

Utilizator pykhNeagoe Alexandru pykh Data 14 martie 2010 15:26:39
Problema 12-Perm Scor 0
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,t1 = 1, t2 = 2, t3 = 6, t4 = 12, n , j = 5, last, aux;
int main()
	{
	freopen(in,"r",stdin);
	freopen(out,"w",stdout);
		scanf("%d", &n);
		for(; j <= n ; ++j)
		{
			aux = t4;
			t4 = t3 + t1 + 2 * ( j - 2 );
			if(t4 > mod) t4 -= mod;
			t1 = t2; t2 = t3; t3 = aux;
		}
		printf("%d\n", t4);
		return 0;
}