ZOJ 1938 Binomial &&poj 2249 (Binomial Showdown )(睡前一水)
2015-01-25 23:23
411 查看
链接:click here
题意:
In how many ways can you choose k elements out of n elements, not taking order into account? Write a program to compute this number.
给你整数n和k,让你求组合数c(n,k)。
代码:
题意:
In how many ways can you choose k elements out of n elements, not taking order into account? Write a program to compute this number.
给你整数n和k,让你求组合数c(n,k)。
代码:
#include <cstdio> #include <cstring> #include <math.h> typedef long long LL; LL ans,n,k; int main() { while(scanf("%lld%lld",&n,&k),n) { ans=1; if(k == 0) { printf("1\n"); continue; } k=n-k>k?k:n-k; //if(k>n-k)k=n-k; for(int i=1; i<=k; i++) { ans=ans*(n-i+1)/i; } printf("%lld\n",ans); } return 0; }
相关文章推荐
- poj 3100 && zoj 2818 ( Root of the Problem ) (睡前一水)
- ZOJ 1938 Binomial Showdown
- (组合数学3.1.2.1)POJ 2249 Binomial Showdown(排列组合公式的实现)
- POJ 题目2249 Binomial Showdown(数学)
- poj 2249 Binomial Showdown
- poj2249 Binomial Showdown 求组合数
- Poj 2249 Binomial Showdown
- [ACM] poj 2249 Binomial Showdown (排列组合公式优化)
- [ACM] poj 2249 Binomial Showdown (排列组合公式优化)
- poj 2249 Binomial Showdown
- POJ2249 Binomial Showdown
- POJ 2249 Binomial Showdown 求组合数C(n,k)
- POJ 2249 Binomial Showdown (连乘整商求组合数)
- POJ 2249 Binomial Showdown(我的水题之路——求n个数里取m个数的值)
- POJ 2249 Binomial Showdown(组合数)
- POJ 2249 Binomial Showdown 求组合数C(n,k)
- poj 3100 (zoj 2818)||ZOJ 2829 ||ZOJ 1938 (poj 2249)
- POJ 2249 Binomial Showdown(排列组合)
- POJ 2249-Binomial Showdown(排列组合计数)
- poj 2249 Binomial Showdown[C(n, m)组合数求解]