///hdu 1028 母函数 一个数有几种相加方式 #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #define INF 1000000009 using namespace std; ; int c1[_max], c2[_max]; int main() { int n,i,j,k; while(cin>>n) { ;i<=n;i…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19589    Accepted Submission(s): 13709 Problem Description "Well, it seems the first problem is too easy. I will let…
给出我初学时看的文章:母函数(对于初学者的最容易理解的) 普通母函数--------->HDU - 1028 例题:若有1克.2克.3克.4克的砝码各一 枚,能称出哪几种重量?各有几种可能方案?如何解决这个问题呢?考虑构造母函数.如果用x的指数表示称出的重量,则:    1个1克的砝码可以用函数1+x表示,    1个2克的砝码可以用函数1+x2表示,(x2表示x的2次方)    1个3克的砝码可以用函数1+x3表示,    1个4克的砝码可以用函数1+x4表示,(1+x)(1+x2)(1+x3…
Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstring> typedef long long LL; LL ans[][]; LL n,anss; LL get(LL x,LL y) { ) return ans[x][y]; ) ; ; ans[x][y]=; LL i; ;i<=y;i++) ans[x][y]+=get(x-y,i); re…
链接:传送门 题意:一个数n有多少种拆分方法 思路:典型母函数在整数拆分上的应用 /************************************************************************* > File Name: 1.cpp > Author: WArobot > Blog: http://www.cnblogs.com/WArobot/ > Created Time: 2017年04月20日 星期四 21时07分09秒 ********…
题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says. "The second problem is, given an positive integer N, we define an equation like this: N=a[1]+a[2…
题意: N=a[1]+a[2]+a[3]+...+a[m];  a[i]>0,1<=m<=N; 例如: 4 = 4;  4 = 3 + 1;  4 = 2 + 2;  4 = 2 + 1 + 1;  4 = 1 + 1 + 1 + 1; 共有5种. 给N,问共有几种构造方式. 思路: 一个数N分解的式子中1的个数可以是0,1,2,3,...,N. 2的个数可以是0,1,2,...,N/2. .... 母函数基础题,, 看代码. 当然也可以用DP(背包) 母函数代码: int N,num;…
题意: 现在你被要求用天平和一些砝码来量一剂药.当然,这并不总是可以做到的.所以你应该找出那些不能从范围[1,S]中测量出来的品质.S是所有重量的总质量. 输入一个n,后面有n个数,表示这n个物品的质量 题解: 注意这个题的题干,这个天平只要能制造出来那个质量差,然后这个质量差就不会输出(看懂第二个样例就行) 这道题是母函数的变化版,没学过母函数的可以看一下:母函数 <普通母函数(HDU - 1028 ) && 指数型母函数(hdu1521)> 代码: 1 #include&l…
 HDU 1028 Ignatius and the Princess III Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says. &q…
题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是dp[i][i].那么dp[i][j]=dp[i][j-1]+dp[i-j][i-j],dp[i][j-1]是累加1到j-1的结果,dp[i-j][i-j]表示的就是最大为j,然后i-j有多少种表达方式啦.因为i-j可能大于j,这与我们定义的j为最大值矛盾,所以要去掉大于j的那些值 /*******…