hdu1028 Ignatius and the Princess III

#include <stdio.h>
#define MAXN 125

int main()
{
	int arr1[MAXN],arr2[MAXN];
	int i,j,k,n;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<=n;++i)
		{
			arr1[i]=1;
			arr2[i]=0;
		}
		for (i=2;i<=n;++i)
		{
			for(j=0;j<=n;++j)
				for (k=0;k+j<=n;k+=i)
				{
					arr2[k+j]+=arr1[j];
				}
			for (j=0;j<=n;++j)
			{
				arr1[j]=arr2[j];
				arr2[j]=0;
			}
		}
		printf("%d\n",arr1[n]);
	}
	return 0;
}

你可能感兴趣的:(hdu1028 Ignatius and the Princess III)