Cod sursa(job #417531)

Utilizator pykhNeagoe Alexandru pykh Data 14 martie 2010 15:18:13
Problema 12-Perm Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 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;
int main()
	{
	freopen(in,"r",stdin);
	freopen(out,"w",stdout);
		scanf("%d", &n);
		val = n;
		for(; j <= n ; ++i, ++j)
		{
			t[i] = t[4 - 1] + t[4 - 3] + 2 * ( j - 2 );
			if(t[ i ] > mod) t[ i ] -= mod;
			last = t[i];
			if(i == 4) i = 0;
		}
		if(n<=4)printf("%d\n", t[n]);
		else printf("%d\n", last);
		return 0;
}