[HDU 1028] Ignatius and the Princess III 母函数
来源:互联网 发布:java服务器开发书籍 编辑:程序博客网 时间:2024/06/08 07:55
http://acm.hdu.edu.cn/showproblem.php?pid=1028
题意:输入一个数 n,求[1, n]中选任意几个数加起来等于 n 的方案有多少种。
思路:母函数 (1 + x^1 + x^2 + x^3 + … + x^n)*(1 + x^2 + x^4 + x^6 +…+ x^(n/2))……(1 + x^n)
#include <cstdio>#include <cstring>#include <iostream>using namespace std;int nex[125],temp[125];int main(){ int n, m; while(cin>>n>>m) cout<<gcd(n, m)<<endl; while(cin>>n){ memset(nex, 0, sizeof(nex)); memset(temp, 0, sizeof(temp)); for(int i = 0; i <= n; i++){ nex[i] = 1; } for(int i = 2; i <= n; i++){ for(int j = 0; j <= n; j++){ for(int k = 0; k <= n && j+k <= n; k += i){ temp[j+k] += nex[j]; } } for(int j = 0; j <= n; j++){ nex[j] = temp[j]; temp[j] = 0; } } cout<<nex[n]<<endl; } return 0;}
0 0
- HDU/HDOJ 1028 母函数 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III(母函数)
- HDU 1028 Ignatius and the Princess III (母函数)
- HDU-1028Ignatius and the Princess III(母函数)
- hdu 1028 Ignatius and the Princess III 母函数
- hdu 1028 Ignatius and the Princess III(母函数)
- hdu 1028 Ignatius and the Princess III 母函数
- HDU 1028 Ignatius and the Princess III(母函数)
- [母函数]HDU 1028 Ignatius and the Princess III
- [hdu 1028] Ignatius and the Princess III (母函数)
- hdu 1028 Ignatius and the Princess III 母函数/dp
- Ignatius and the Princess III 【HDU--1028-母函数】
- hdu 1028 Ignatius and the Princess III ( 母函数)
- hdu 1028 Ignatius and the Princess III (母函数)
- HDU 1028 Ignatius and the Princess III 母函数
- hdu-1028 Ignatius and the Princess III 【母函数】
- HDU -- 1028 Ignatius and the Princess III(母函数)
- HDU 1028 Ignatius and the Princess III(母函数)
- 求助SQL Server I/O设备错误!!!
- Android性能优化之提高ListView性能的技巧
- 71道经典Android面试题和答案,重要知识点都包含了
- std::vector中erase函数的用法
- 2.使用地图API,获取经纬度并传到服务器的可行方法
- [HDU 1028] Ignatius and the Princess III 母函数
- Logger打印日志
- Deep learning Reading List
- 7.29 盒子
- 深入JDK
- Qt 5.3 下OpenCV 2.4.11 开发(3)简单的GUI项目
- hdu 5318 The Goddess Of The Moon 【矩阵快速幂】
- 合唱队形-动态规划
- hdu5313 求构成完全二分图需要的最多的边数 染色+背包求最小差异