N - Binomial Showdown (组合数学)
Description
Write a program to compute this number.
Input
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
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
解题思路:简单求组合数,数据比较小,直接暴力枚举运算即可!
AC代码:
#include<iostream>
using namespace std;
int main(){
int n,k;long long ans;//开long long,避免数据溢出
while(cin>>n>>k&&(n+k)){
if(n-k<k)k=n-k;
ans=;
for(int i=;i<=k;++i)ans=ans*(n-i+)/i;
cout<<ans<<endl;
}
return ;
}
N - Binomial Showdown (组合数学)的更多相关文章
- Binomial Showdown
Binomial Showdown TimeLimit: 1 Second MemoryLimit: 32 Megabyte Totalsubmit: 2323 Accepted: 572 D ...
- zoj 1938 Binomial Showdown 组合数裸基础
Binomial Showdown Time Limit: 2 Seconds Memory Limit: 65536 KB In how many ways can you choose ...
- (组合数学3.1.2.1)POJ 2249 Binomial Showdown(排列组合公式的实现)
/* * POJ_2249.cpp * * Created on: 2013年10月8日 * Author: Administrator */ #include <iostream> #i ...
- Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)
Binomial Coeffcients TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 输入 输出 示例输入 1 1 10 2 9 ...
- POJ 2249 Binomial Showdown
// n 个 数 取 k个数的取法// C(n,k) 注意些细节#include <iostream> #include <string> #include<sstrea ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- POJ 2249-Binomial Showdown(排列组合计数)
Binomial Showdown Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18457 Accepted: 563 ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
随机推荐
- DBA的40条军规
DBA操作规范 1.涉及业务上的修改/删除数据,在得到业务方.CTO的邮件批准后方可执行,执行前提前做好备份,必要时可逆. 2.所有上线需求必须走工单系统,口头通知视为无效. 3.在对大表做表结构变更 ...
- codevs——1080 线段树练习
1080 线段树练习 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Description 一行N个方格,开始每个格子里都有 ...
- Ubuntu 16.04 GNOME添加桌面图标/在桌面上显示图标
GNOME默认不能在桌面上创建文件夹,但是可以通过工具设置:用gnome-tweak-tool设置Nautilus接管桌面即可. 安装: sudo apt-get install gnome-twea ...
- u启动为苹果笔记本重装win7系统教程
准备更换系统的苹果笔记本一台! 上述需要准备的东西均准备好以后我们就开始今天的教程了!! 首先,将已经制作好启动盘的u启动u盘插入到苹果笔记本上的usb插口,然后开机! 由于苹果笔记本电脑 ...
- Linux纯Shell实现DNSPod动态域名
http://www.anrip.com/post/872 开发背景: 公司有台嵌入式拨号上网设备,内置busybox和完整wget命令(支持https协议),但没有curl.python.ruby. ...
- 【LeetCode-面试算法经典-Java实现】【067-Add Binary(二进制加法)】
[067-Add Binary(二进制加法)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given two binary strings, return thei ...
- 【剑指Offer】俯视50题之31 - 40题
面试题31连续子数组的最大和 面试题32从1到n整数中1出现的次数 面试题33把数组排成最小的数 面试题34丑数 面试题35第一个仅仅出现一次的字符 面试题36数组中的逆序对 面试题37两个链表的第一 ...
- MariaDB -- 数据类型
Mariadb 的数据类型 MariaDB数据类型可以分为数字,日期和时间以及字符串值. 使用数据类型的原则:够用就行, 尽量使用范围小的,而不用大的 常用的数据类型 整数:int, bit 小数:d ...
- Python全栈
Python基础 Python基础01 Hello World! Python基础02 基本数据类型 Python基础03 序列 Python基础04 运算 Python基础05 缩进和选择 Pyth ...
- scikit-learn:3.3. Model evaluation: quantifying the quality of predictions
參考:http://scikit-learn.org/stable/modules/model_evaluation.html#scoring-parameter 三种方法评估模型的预測质量: Est ...