Cod sursa(job #592602)

Utilizator ProtomanAndrei Purice Protoman Data 29 mai 2011 13:45:09
Problema Sortari2 Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <algorithm>
#include <stdio.h>

#define MAX 1024
#define restRez 999017
#define ll long long

using namespace std;

int n;
int a[MAX];
ll nFact = 1;

int main()
{
	freopen("sortari2.in", "r", stdin);
	freopen("sortari2.out", "w", stdout);

	scanf("%d", &n);

	a[0] = a[1] = 1;
	for (int i = 2; i <= n; i++)
		nFact = (nFact * i) % restRez;
	for (int i = 2; i <= 2 * n; i++)
		a[i] = (a[i - 1] + a[i - 2]) % restRez;

	printf("%d\n", (nFact + restRez - a[2 * n - 2]) % restRez);

	fclose(stdin);
	fclose(stdout);
	return 0;
}