首页 > 其他 > 详细

母函数

时间:2020-09-28 17:42:55      阅读:30      评论:0      收藏:0      [点我收藏+]

 

 

#include <iostream>

using namespace std;
typedef long long LL;
const int N=121;   //题目所求数字和的最大值
const int maxn=125;   //你所拥有的数字的值
LL c1[N],c2[N];  //c1  最终合并的多项式   c2临时合并的多项式
int n=121;

void init()
{
    c1[0]=1;
    for(int i=1;i<=maxn;i++)  //遍历你所拥有的数
    {
        for(int j=0;j<N;j+=i)  //每次加上你所拥有的数
        {
            for(int k=0;j+k<N;k++)  //从x^0到x^N遍历一遍
            {
                c2[j+k]+=c1[k];
            }
        }
        for(int j=0;j<n;j++)
        {
            c1[j]=c2[j];
            c2[j]=0;
        }
    }
}
void solve()
{
    int n;
    cin>>n;
    cout<<c1[n]<<endl;
    return ;
}
int main()
{
//    int t;
//    cin>>t;
//    while(t--)
//    {
//        solve();
//    }
init();
while(scanf("%d", &n) != EOF){
         printf("%I64d\n", c1[n]);
     }
    return 0;
}

 

母函数

原文:https://www.cnblogs.com/AAAzhuo/p/13745515.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!