Cod sursa(job #165564)

Utilizator gabitzish1Gabriel Bitis gabitzish1 Data 26 martie 2008 12:24:01
Problema Sandokan Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <stdio.h>

int n, k, v[5005];
const int mod = 2000003;

long long comb(int x, int y)
{
	long long int i, s = 1;
	for (i = x - y + 1; i <= x; i++){ s *= i;}
	for (i = 2; i <= y; i++){ s /= i; s %= mod;}
	return s;
}


int calcul(int n)
{
	if (n <= k) return 1;
	else return ((comb(n,k) % mod) * (calcul(n - k + 1) % mod) % mod);
}


void citire()
{
	freopen("sandokan.in","r",stdin);
	freopen("sandokan.out","w",stdout);

	int i, rez;
	scanf("%d %d",&n,&k);
	for (i = 1; i <= n; i++) scanf("%d",v + i);

	rez = calcul(n);
	printf("%d\n",rez);
}

int main()
{
	citire();
	return 0;
}