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 ...
随机推荐
- 【small项目】MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link ...
- 单调队列&单调栈 基础
参考博客https://www.cnblogs.com/tham/p/8038828.html 例题 poj 2823 Sliding Window Time Limit: 12000MS Me ...
- HDU 5640 King's Cake【模拟】
题意: 给定长方形,每次从中切去一个最大的正方形,问最终可以得到多少正方形. 分析: 过程类似求gcd,每次减去最小的边即可. 代码: #include <cstdio> #include ...
- 奥多朗WIFI 插座
https://aoduolang.tmall.com/category-1089563810.htm?spm=a1z10.1-b.w11212542-12917613245.12.tTWFSc&am ...
- JFileChooser 中文API
javax.swing类 JFileChooser java.lang.Object java.awt.Component java.awt.Container javax.swing.JCompon ...
- frameset怎样实现整个页面的跳转
登录页面login.jsp,系统登录成功后展示mainLayout.jsp, 我如今用frameset框架把页面mainLayout.jsp分为三部分,head.jsp..left.jsp.right ...
- HDU 1542 Atlantis (线段树 + 扫描线 + 离散化)
Atlantis Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total S ...
- MySQL-PREPARE语句
MySQL-PREPARE语句 功能介绍: MySQL准备语句用法 为了使用MySQL准备语句,您需要使用其他三个MySQL语句如下: PREPARE - 准备执行的声明. EXECUTE - 执行由 ...
- @Override用在哪儿
帮朋友改一段代码,看到好多红叉都是指向@Override. 是这样,他代码里写了一个接口.方法都用抽象函数声明在接口类里.然后在继承自这个接口的实现类里写详细方法的空壳 ...
- JavaScript实现页面重载 - 535种方式
location = location ... and a 534 other ways to reload the page with JavaScript location = location ...