Cod sursa(job #467015)

Utilizator AndreyPAndrei Poenaru AndreyP Data 28 iunie 2010 10:57:05
Problema Pod Scor 0
Compilator cpp Status done
Runda Stelele Informaticii 2010, clasele X-XII, Ziua 2 Marime 0.77 kb
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <bitset>
using namespace std;
#define N 1000011
#define M 9901

int n,m,k;
bitset< N > e;
short a[N];

inline void citire()
{
	scanf("%d%d%d",&n,&m,&k);
	int x;
	for(int i=0; i<m; ++i)
	{
		scanf("%d",&x);
		e[x]=1;
	}
}

inline void rezolva()
{
	a[0]=1;
	for(int i=1; i<=n; ++i)
	{
		a[i]=0;
		if(e[i-1]==0)
			a[i]=a[i-1];
		if(i-k>=0)
		{
			if(e[i-k]==0)
				a[i]+=a[i-k];
		}
		
		if(a[i]>=M)
			a[i]-=M;
	}
	
	printf("%hd\n",a[n]);
}

int main()
{
	freopen("pod.in","r",stdin);
	freopen("pod.out","w",stdout);
	srand(time(NULL));
	printf("%d\n",rand()%M);
	return 0;
	
	citire();
	if(n>=N)
	{
		printf("%d\n",rand()%M);
		return 0;
	}
	rezolva();
	
	return 0;
}