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.

Input

The input will contain one or more test cases.

Each test case consists of one line containing two integers n (n>=1) and k (0<=k<=n).

Input is terminated by two zeroes for n and k.

Output

For each test case, print one line containing the required number. This number will always fit into an integer, i.e. it will be less than 2
31.

Warning: Don't underestimate the problem. The result will fit into an integer - but if all intermediate results arising during the computation will also fit into an integer depends on your algorithm. The test cases will go to the limit.

Sample Input

4 2
10 5
49 6
0 0

Sample Output

6
252
13983816

求C(n,k),模板题
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define M 105 ll n,k; int main()
{
ll i,j;
while(cin>>n>>k)
{
if(n==0&&k==0)
break;
if(k==n)
{
cout<<1<<endl;
continue;
} if(n-k<k)
k=n-k;
ll ans=1;
for(i=1;i<=k;i++)
{
ans=ans*(n-i+1)/i;
}
cout<<ans<<endl;
}
}

  

poj_2249_Binomial Showdown的更多相关文章

  1. Binomial Showdown

    Binomial Showdown TimeLimit: 1 Second   MemoryLimit: 32 Megabyte Totalsubmit: 2323   Accepted: 572 D ...

  2. zoj 1938 Binomial Showdown 组合数裸基础

    Binomial Showdown Time Limit: 2 Seconds      Memory Limit: 65536 KB In how many ways can you choose ...

  3. POJ 2249-Binomial Showdown(排列组合计数)

    Binomial Showdown Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18457   Accepted: 563 ...

  4. POJ 2249 Binomial Showdown

    // n 个 数 取 k个数的取法// C(n,k) 注意些细节#include <iostream> #include <string> #include<sstrea ...

  5. SDUT1061Binomial Showdown(组合数)

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1061 题意 : 表示这个题的英文没看懂,就看懂 ...

  6. (组合数学3.1.2.1)POJ 2249 Binomial Showdown(排列组合公式的实现)

    /* * POJ_2249.cpp * * Created on: 2013年10月8日 * Author: Administrator */ #include <iostream> #i ...

  7. N - Binomial Showdown (组合数学)

    Description In how many ways can you choose k elements out of n elements, not taking order into acco ...

  8. AtCoder AGC005E Sugigma: The Showdown (博弈论)

    题目链接 https://atcoder.jp/contests/agc005/tasks/agc005_e 题解 完了真的啥都不会了-- 首先,显然如果某条A树的边对应B树上的距离大于等于\(3\) ...

  9. Atcoder Grand Contest 005 E - Sugigma: The Showdown(思维题)

    洛谷题面传送门 & Atcoder 题面传送门 记先手移动棋子的树为红树,后手移动棋子的树为蓝树. 首先考虑一个性质,就是如果与当前红色棋子所在的点相连的边中存在一条边,满足这条边的两个端点在 ...

随机推荐

  1. 静态化HttpClient

    实现方法: public class HttpClientHelper { private static HttpClient _client; public static HttpClient Ge ...

  2. Python pip windows安装

    参考页面: [1] : https://pip.pypa.io/en/latest/installing.html [2] : http://stackoverflow.com/questions/4 ...

  3. WinSock WSAEventSelect 模型

    在前面我们说了WSAAsyncSelect 模型,它相比于select模型来说提供了这样一种机制:当发生对应的IO通知时会立即通知操作系统,并调用对应的处理函数,它解决了调用send和 recv的时机 ...

  4. $smarty->assign('','')查询结果发送给模板

    $article = one("select * from article WHERE id = '$id'"); $smarty->assign('abc(随便定义)',' ...

  5. 21_AOP_Advice增强2(异常、引介)

    [异常抛出增强] 异常抛出异常最适合的应用场景:事务管理. 当参与事务的某个Dao发生异常时,事务管理器就必须回滚事务. [异常抛出增强 例子] [操作数据库的Dao类:PersonDao.java] ...

  6. 《ArcGIS Runtime SDK for Android开发笔记》——问题集:Error:Error: File path too long on Windows, keep below 240 characters

    1.前言 在使用Android Studio开发环境时,经常会爆出以下错误,虽然具体细节内容各有不同,但是说明的都是同一个问题,在windows中使用过长的路径,超过240字符. Error:Erro ...

  7. log4j 配置详解

    参考如下两个网址,讲的很详细,先看第一个再看第二个: log4j使用介绍:http://swiftlet.net/archives/683 java日志处理组件log4j--log4j.xml配置详解 ...

  8. 让CPU的占用率听你的指挥

    此题目具有很大的想象空间,尤其是多核环境下. 详见:http://hi.baidu.com/jeschou/item/53da6df6a8d25209d99e722d

  9. SSM整合的简单实现

    整合需要的jar包和源码将在文末给出 本文参考黑马程序员视频,由于视频用的环境和我使用的环境不同,建议使用我的环境及jar包(比较新) 一 整合思路 第一步 整合dao层 mybatis和spring ...

  10. ring0 恢复SSDTHook

    原理: 用ZwQuerySystemInformation 功能号为11(SystemModuleInformation)  得到所有系统模块的地址 遍历搜索得到ntos模块的基地址 读Ntos模块到 ...