// n 个 数 取 k个数的取法
// C(n,k) 注意些细节
#include <iostream>
#include <string>
#include<sstream>
#include <cmath>
#include <map>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define LL long long
LL C(int n,int k)
{
LL m=;
if(k>n/) k=n-k; // 不加这句会超时 比如C[10^9][10^9 - 1]
int i;
for(i=;i<=k;i++)
{
m*=(n-i+);
m/=i;
}
return m;
}
int main()
{
int n,k;
while(scanf("%d %d",&n,&k),n|k)
{
printf("%lld\n",C(n,k));
}
return ;
}

POJ 2249 Binomial Showdown的更多相关文章

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

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

  2. poj 3100 (zoj 2818)||ZOJ 2829 ||ZOJ 1938 (poj 2249)

    水题三题: 1.给你B和N,求个整数A使得A^n最接近B 2. 输出第N个能被3或者5整除的数 3.给你整数n和k,让你求组合数c(n,k) 1.poj 3100 (zoj 2818) Root of ...

  3. Binomial Showdown

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

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

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

  5. POJ 2249 暴力求组合数

    Binomial Showdown Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22692   Accepted: 692 ...

  6. POJ 2249

    #include<stdio.h> longlong sum; int main() { int k,n,m; while(~scanf("%d%d",&n,& ...

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

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

  8. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  9. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

随机推荐

  1. 堆排序 Heap Sort

    堆排序虽然叫heap sort,但是和内存上的那个heap并没有实际关系.算法上,堆排序一般使用数组的形式来实现,即binary heap. 我们可以将堆排序所使用的堆int[] heap视为一个完全 ...

  2. PLSQL:plsql中文乱码,显示问号

    PLSQL执行sql语句,不识别中文,输出的中文标题显示成问号???? 1. 登陆plsql,执行sql语句,输出的中文标题显示成问号????:条件包含中文,则无数据输出

  3. hadoop 1 testcase运行方法

       转入hadoop2.0后,逐渐忘记了之前做testcase运行的方法,记录一下:    ant -Dtestcase=Test***    如果只运行core包得testcase可以    an ...

  4. RTP-实时协议

    RTP,实时协议被用来为应用程序如音频,视频等的实时数据的传输提供端到端(end to end)的网络传输功能.传输的模型可以是单点传送或是多点传送.数据传输被一个姐妹协议——实时控制协议(RTCP) ...

  5. Python十分钟学会

    初试牛刀 假设你希望学习Python这门语言,却苦于找不到一个简短而全面的入门教程.那么本教程将花费十分钟的时间带你走入Python的大门.本文的内容介于教程(Toturial)和速查手册(Cheat ...

  6. React组件生命周期-正确执行运行阶段的函数

    一. 二. <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset=" ...

  7. dojo新建widget步骤----主要针对widget路径

    一,新建目录 二,新建文件 三,写urtil widget代码 四,写RedTextDialog代码 五,写HTML代码 =====================如有不懂,结合http://blog ...

  8. Database: Normal form

    refer to wikipedia--- 1NF(first normal form): 1. There's no top-to-bottom ordering to the rows. 2. T ...

  9. C# 文本文件打印类库(C#)

    我写了一个打印文本文件的类库,功能包括:打印预览.打印.打印时可以选择打印机,可以指定页码范围.调用方法非常简单:TextFilePrinter p = new TextFilePrinter(tbx ...

  10. mongodb unset/set 删除/增加字段

    删除全部文档的name字段 db.users.update({},{$unset: {"name":""}},{nulti:true}) 增加全部文档的name ...