Cod sursa(job #318655)

Utilizator GheorgheMihaiMihai Gheorghe GheorgheMihai Data 28 mai 2009 21:27:42
Problema Sandokan Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<stdio.h>
#include<string.h>
int n,p;
int v1[5002];
int v2[5002];

void read()
{
	freopen("sandokan.in","r",stdin);
	freopen("sandokan.out","w",stdout);
	scanf("%d%d",&n,&p);
}

void comb()
{
	int i,j;
	v1[1]=1;
	for(i=2;i<n;i++)
	{
		for(j=1;j<p;j++)
		{
			v2[j]=v1[j-1]+v1[j];
			if(v2[j]>=2000003)
				v2[j]-=2000003;
		}
		memcpy(v1,v2,sizeof(v2));
	}
	printf("%d\n",v2[p-1]);
}

int main()
{
	read();
	comb();
	return 0;
}