现在的位置: 首页 > 综合 > 正文

hdu 1028 Ignatius and the Princess III

2018年12月29日 ⁄ 综合 ⁄ 共 281字 ⁄ 字号 评论关闭

整数拆分

母函数模板题

 

 

 

#include<stdio.h>
int c1[121],c2[121];
int main()
{
    int t,n,m,i,j,s,k;    
    while(scanf("%d",&n)!=EOF)
    {
        for(j=0;j<=n;j++)
        {c1[j]=1;c2[j]=0;}
        for(i=2;i<=n;i++)
        {
             for(j=0;j<=n;j++)      
                for(k=0;k+j<=n;k=k+i)
                    c2[j+k]+=c1[j];
                for(j=0;j<=n;j++)
                {
                    c1[j]=c2[j];c2[j]=0;
                }
        }
            
        printf("%d\n",c1[n]);
    }
    return 0;
}

 

抱歉!评论已关闭.