nyist_xiaod

When you want to give up, think of why you persist until now.

HDU 1028 Ignatius and the Princess III(母函数)

题目链接:Click here~~

母函数第二题,整数划分。

#include <stdio.h>
#include <string.h>
const int MAX=120;
int main()
{
    int n,c1[MAX+5],c2[MAX+5];
    while(~scanf("%d",&n))
    {
        memset(c1,0,sizeof(c1));
        memset(c2,0,sizeof(c2));
        c1[0]=1;
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
            {
                for(int k=0;j+k*i<=n;k++)
                {
                    c2[j+k*i] += c1[j];
                }
            }
            memcpy(c1,c2,sizeof(c2));
            memset(c2,0,sizeof(c2));
        }
        printf("%d\n",c1[n]);
    }
    return 0;
}


阅读更多
文章标签: c
上一篇HDU 2082 找单词(母函数)
下一篇HDU 1085 Holding Bin-Laden Captive!(母函数)
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭