Poj 2249 Binomial Showdown
2013-06-16 17:54
381 查看
题目链接:http://poj.org/problem?id=2249
简单的组合题。
C(n,m) = C(n,m-1) * (n-m+1) / m.
C(n,m) = C(n,n-m).
简单的组合题。
C(n,m) = C(n,m-1) * (n-m+1) / m.
C(n,m) = C(n,n-m).
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <iostream> using namespace std; long long C(int n,int m) { m = m<(n-m) ? m : (n-m); if(m == 0) return 1; long long ans = 1; for(int i=1;i<=m;i++) { ans = ans *(n-i+1)/i; } return ans; } int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int n,m; while(scanf(" %d %d",&n,&m)!=EOF) { if(n == 0 && m == 0) break; printf("%lld\n",C(n,m)); } return 0; }
相关文章推荐
- [ACM] poj 2249 Binomial Showdown (排列组合公式优化)
- POJ 2249 Binomial Showdown
- POJ 2249 Binomial Showdown(我的水题之路——求n个数里取m个数的值)
- ZOJ 1938 Binomial &&poj 2249 (Binomial Showdown )(睡前一水)
- [ACM] poj 2249 Binomial Showdown (排列组合公式优化)
- POJ 题目2249 Binomial Showdown(数学)
- (组合数学3.1.2.1)POJ 2249 Binomial Showdown(排列组合公式的实现)
- [ACM] poj 2249 Binomial Showdown (排列组合公式优化)
- POJ 2249 Binomial Showdown(组合数)
- poj 2249 Binomial Showdown[C(n, m)组合数求解]
- poj 2249 Binomial Showdown(组合数 公式优化)
- POJ2249 Binomial Showdown
- poj 2249 Binomial Showdown
- poj 2249 Binomial Showdown
- POJ - 2249 - Binomial Showdown - (组合数)
- poj 2249 Binomial Showdown
- POJ 2249 Binomial Showdown 求组合数C(n,k)
- POJ 2249-Binomial Showdown(排列组合计数)
- POJ 2249 Binomial Showdown 求组合数C(n,k)
- POJ 2249 Binomial Showdown 笔记