Cod sursa(job #167706)

Utilizator andrei-alphaAndrei-Bogdan Antonescu andrei-alpha Data 29 martie 2008 22:32:39
Problema Sandokan Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <stdio.h>
#define N 2000001
#define R 2000003
bool v[N];
int n,m,k,rez=1;
void scan()
{
	int e;
	freopen("sandokan.in", "r",stdin);
	freopen("sandokan.out", "w",stdout);
	scanf("%d%d", &n,&k);
	m=n;
	for(int i=1;i<=n;++i)
	{
		scanf("%d", &e);
		if(v[e])
			--m;
		v[e]=1;
	}
}
void solve()
{
	long long aux;
	while(m)
	{
		aux=1;
		for(int i=1;i<=m;++i)
			aux*=i;
		for(int i=1;i<=m-k;++i)
			aux/=i;
		aux/=k;
		rez*=(aux%R);
		m-=k+1;
	}
	printf("%d\n", rez%R);
}
int main()
{
	scan();
	solve();
	return 0;
}