码迷,mamicode.com
首页 > 其他好文 > 详细

HDUOj Ignatius and the Princess III 题目1002

时间:2017-04-12 09:29:58      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:types   word   sso   std   ring   top   amp   keyword   key   

??

母函数  组合数学

#include<stdio.h>    

int c1[125];  

int c2[125];  

int main()  

{  

    int n,i,j,k;  

    while(scanf("%d",&n)!=EOF)  

    {  

        for(i=0;i<=n;i++)  

        {  

            c1[i]=1;  

            c2[i]=0;  

        }  

        for(i=2;i<=n;i++)  

        {  

            for(j=0;j<=n;j++)  

                for(k=0;k+j<=n;k=k+i)  

                    c2[k+j]=c2[k+j]+c1[j];  

            for(j=0;j<=n;j++)  

            {  

                c1[j]=c2[j];  

                c2[j]=0;  

            }  

        }  

        printf("%d\n",c1[n]);  

    }  

    return 0;  

}  

HDUOj Ignatius and the Princess III 题目1002

标签:types   word   sso   std   ring   top   amp   keyword   key   

原文地址:http://www.cnblogs.com/brucemengbm/p/6697514.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!