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 ...
随机推荐
- Sumdiv(poj1845)
题意:求A^B的因子的和. /* 首先将A分解 A=p1^a1*p2^a2*...*pn*an A^B=p1^a1B*p2^a2B*...*pn*anB 因子之和sum=(1+p1+p1^2+...+ ...
- Linux下汇编语言学习笔记51 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- PKCS填充方式
1)RSA_PKCS1_PADDING 填充模式,最常用的模式要求: 输入 必须 比 RSA 钥模长(modulus) 短至少11个字节, 也就是 RSA_size(rsa) – 11.如果输入的明文 ...
- <项目><day11>查看用户浏览过的商品
<项目>查看用户浏览过的商品 1.创建一个entity包储存实体对象 1.1创建一个Product的类存储实体对象 对象具有以下属性,并添加set和get方法,含参和不含参的构造方法,to ...
- Eclipse-Java代码规范和质量检查插件-FindBugs
FindBugs 是由马里兰大学提供的一款开源 Java静态代码分析工具.FindBugs通过检查类文件或 JAR文件,将字节码与一组缺陷模式进行对比从而发现代码缺陷,完成静态代码分析.FindBug ...
- Ubuntu清理内存命令(效果不明显)
注意:最好不要在生产环境上使用!!! 1.检查内存使用情况 watch -n 3 free -m watch -n 3 cat /proc/meminfo 2.清理 #释放页缓存 echo 1 > ...
- WIN10中使用Hyper-V 配置虚拟机宿主机互ping
在Windows10 Hyper-V 中安装 Linux (Ubuntu16.04)虚拟机无法 ping 通宿主机,宿主机可以ping通虚拟机. 这种情况下关闭 Windows 防火墙就能ping通 ...
- 当遇到Mac的Excel或者Word老是重复崩溃的时候
打开Number,新建文件然后导出为Excel.之后再用Excel打开,一切都OK了.
- laravel notification
mail篇 public function via($notifiable) { return ['mail']; } 1.新建notification类 php artisan make:notif ...
- 安卓数据传递之---putextra与putextras
一.public Intent putExtra (String name, double[] value) 设置方法 intent.putExtra("aaa", "b ...