hut 1574 组合问题 解题报告
2011-08-07 19:36
316 查看
链接:http://openoj.awaysoft.com/JudgeOnline/problem.php?id=1574
3 3
0 0
10
本题是一个纯组合问题,题意也比较简单即:从无限多重集中取若干元素的组合数
N = C( n+m-1 , m )
再通过组合数性质C( n, m ) = C( n-1, m ) + C( n-1, m-1 ),直接打表无压力水过。
Description
有n 种颜色的球,每种颜色的球的个数有任意多个,从中取m个,问有多少种取法Input
每行2个正整数 n,m(<=31) ,n=0,m=0结束.
Output
输出有多少种取法
Sample Input
2 23 3
0 0
Sample Output
310
本题是一个纯组合问题,题意也比较简单即:从无限多重集中取若干元素的组合数
N = C( n+m-1 , m )
再通过组合数性质C( n, m ) = C( n-1, m ) + C( n-1, m-1 ),直接打表无压力水过。
#include <stdio.h> #include <stdlib.h> long long a[40][40]; void fun( ) { a[1][0]=a[1][1]=1; for( int i=2; i<40; ++i ) { a[i][0]=1; a[i][1]=i; for( int j=2; j<40; ++j ) { a[i][j]=a[i-1][j]+a[i-1][j-1]; } } } int main() { fun( ); int n, m; while( scanf( "%d%d", &n, &m ) != EOF , n+m) { printf( "%lld\n", a[n+m-1][m] ); } return 0; }
相关文章推荐
- 动态规划解乘法表问题——算法解题报告
- bzoj 1052 覆盖问题 贪心 解题报告
- 一中OJ #3167 排列组合数计算[2] | 高级数论 组合计数 | 解题报告
- 石子问题解题报告
- 迷宫问题(2) 解题报告
- codevs 1282 约瑟夫问题 树状数组正解 解题报告
- 【解题报告】最近点对问题 算法设计与分析 分治算法 openjudge
- 【ACM训练计划】 数论、组合数学 好题精选+解题报告
- 洛谷 1869 愚蠢的组合数 Lucas定理 解题报告
- Hut 新生训练赛第二场 迟来的解题报告
- HDU:2041上楼梯问题解题报告
- 01背包问题的解题报告
- NOIP 1998 上下车问题 解题报告
- 动态规划解机器调度问题——算法解题报告
- POJ 1017 装箱问题 解题报告
- codevs 1222 信与信封问题 二分图 匈牙利 解题报告
- codevs 2602 最短路径问题 Floyd 解题报告
- codevs1295 N皇后问题 解题报告
- codevs 1231 最优布线问题 并查集 解题报告
- Hut_Csust 新生友谊赛第一场 解题报告