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