hdu1398 Square Coins 母函数

该博客探讨了一种整数拆分问题,其中给定一系列平方数(如1, 4, 9等),求解用这些数如何组合成特定整数n的所有方法数量。例如,当n为10时,有4种组合方式。通过母函数G(x)进行多项式计算,可以得到所有可能的组合数。" 84841792,5346649,CentOS7 安装及配置Filebeat与Logstash,"['ELK', 'Logstash', 'Filebeat', 'Elasticsearch', '日志分析']
摘要由CSDN通过智能技术生成
People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (=17^2), i.e., 1-credit coins, 4-credit coins, 9-credit coins, ..., and 289-credit coins, are available in Silverland.

There are four combinations of coins to pay ten credits

题意:一个整数拆分问题。假设给你一堆数:1,4,9……(1*1,2*2,3*3……),给你一个整数n,计算n由这些数构成的总共组合数量。比如n=10,有4种:

1) 10个1;

2) 两个4两个2;

3) 一个4六个1;

4)一个1一个9;

那么构成的母函数G(x)=(1+x+x^2+x^3...)*(1+x^4+x^8+x^16+...)*(1+x^9+x^18+x^27)...多项式计算出来的系数就是方案数。

#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define LL long long
#define maxn 10001
#define INF 2147483646
using namespace std;
int a[maxn],b[maxn];
int 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值