HDU 1085

#include <iostream>
using namespace std;
int c1[10002],c2[10002],a[3]={1,2,5},b[3];
int main()
{
	int n,m,i,j,k,sum;
	while(cin>>n>>m>>k,n+m+k)
	{
		b[0]=n;b[1]=m;b[2]=k;
		sum=0;
		for(i=0;i<3;i++)
		{
			sum+=a[i]*b[i];
		}
		memset(c1,0,sizeof(c1));
		memset(c2,0,sizeof(c2));
		c1[0]=1;//这个不要忘了
		for(i=0;i<3;i++)//钱的种类
		{
			for(j=0;j<=sum;j++)
			{
				if(c1[j])
					for(k=0;k+j<=sum&&k<=a[i]*b[i];k+=a[i])
						c2[k+j]+=c1[j];
			}
			for(j=0;j<=sum;j++)
			{
				c1[j]=c2[j];
				c2[j]=0;
			}
		}
		k=0;
		for(i=1;i<=10000;i++)
			if(!c1[i])
			{
				k=i;
				break;
			}
		cout<<k<<endl;
	}
	return 0;
}

你可能感兴趣的:(c,include)