#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