首页 > 代码库 > 整数划分母函数
整数划分母函数
http://acm.nyist.net/JudgeOnline/problem.php?pid=90
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <climits>#include <string>#include <iostream>#include <map>#include <cstdlib>#include <list>#include <set>#include <queue>#include <stack>using namespace std;int c[10000];int c1[10000];int main(){ int n; int val[100], sum[100]; while (cin >> n){ for (int i = 0; i < n; i++) val[i] = i + 1, sum[i] = n / (i + 1); memset(c, 0, sizeof(c)); c[0] = 1; for (int i = 0; i < n; i++){ for (int j = 0; j <= sum[i]; j++){ for (int k = 0; k + j*val[i] <= n; k++) c1[k + j*val[i]] += c[k]; } for (int j = 0; j <= n; j++) c[j] = c1[j], c1[j] = 0; } printf("%d\n", c[n]); } return 0;}
整数划分母函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。