Pagini recente » Cod sursa (job #194021) | Cod sursa (job #2624972) | Cod sursa (job #938158) | Cod sursa (job #838786) | Cod sursa (job #998096)
Cod sursa(job #998096)
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("sortari2.in");
ofstream g("sortari2.out");
#define MaxN 1010
#define MOD 999017
int N,Perm,Sol;
int Best[MaxN*2] = {1};
int main()
{
f >> N;
Perm = 1;
for(int i=1;i<=N;i++)
Perm = (1LL*Perm*i)%MOD;
for(int i=1;i<=(N<<1);i++)
Best[i] = (Best[i-1]+Best[i-2])%MOD;
for(int i=1;i<N;i++)
Sol = (Sol+Best[(i<<1)-1])%MOD;
Sol = (Sol+Best[(N<<1)-3])%MOD;
g << (Perm-Sol+MOD)%MOD;
}