Cod sursa(job #466980)

Utilizator mathboyDragos-Alin Rotaru mathboy Data 28 iunie 2010 10:22:04
Problema Pod Scor 5
Compilator cpp Status done
Runda Stelele Informaticii 2010, clasele X-XII, Ziua 2 Marime 0.42 kb
#include <cstdio>

#define mod 9901

int n, m, k, a, cnt,i, pr1 = 1;
using namespace std;

int main ()
{
	freopen ("pod.in", "r", stdin);
	freopen ("pod.out", "w", stdout);
	scanf ("%d%d%d\n", &n, &m, &k);
	for (i = 1; i <= m; i++)
	{
		scanf ("%d", &a);
		if (a == n) ++cnt;
	}
	if (cnt == 1) 
	{
		printf ("0\n");
		return 0;
	}
	while (n > 0)
	{
		pr1 = (pr1 * (n - k + 2)) % mod;
		n -= k;
	}
	printf ("%d\n", pr1);
	return 0;
}