UVa 369 - Combinations
题目大意:给两个数n, m,求C(n, m)。用java直接写就好了。
import java.io.*;
import java.util.*;
import java.math.*; class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
BigInteger[] fact = new BigInteger[110];
fact[0] = BigInteger.ONE;
for (int i = 1; i <= 100; i++)
fact[i] = fact[i-1].multiply(BigInteger.valueOf(i));
int n, m;
while (sc.hasNext())
{
n = sc.nextInt();
m = sc.nextInt();
if (n == 0 && m == 0) break;
BigInteger ans = fact[n].divide(fact[m]).divide(fact[n-m]);
System.out.println(n + " things taken " + m + " at a time is " + ans + " exactly.");
} }
}
UVa 369 - Combinations的更多相关文章
- 10_放置街灯(Placing Lampposts,UVa 10859)
问题来源:刘汝佳<算法竞赛入门经典--训练指南> P70 例题30: 问题描述:有给你一个n个点m条边(m<n<=1000)的无向无环图,在尽量少的节点上放灯,使得所有边都被照 ...
- UVa 10012 - How Big Is It? 堆球问题 全排列+坐标模拟 数据
题意:给出几个圆的半径,贴着底下排放在一个长方形里面,求出如何摆放能使长方形底下长度最短. 由于球的个数不会超过8, 所以用全排列一个一个计算底下的长度,然后记录最短就行了. 全排列用next_per ...
- POJ 1087 A Plug for UNIX / HDU 1526 A Plug for UNIX / ZOJ 1157 A Plug for UNIX / UVA 753 A Plug for UNIX / UVAlive 5418 A Plug for UNIX / SCU 1671 A Plug for UNIX (网络流)
POJ 1087 A Plug for UNIX / HDU 1526 A Plug for UNIX / ZOJ 1157 A Plug for UNIX / UVA 753 A Plug for ...
- poj1285 Combinations, Once Again(泛化背包)
题目传送门 Combinations, Once Again Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1897 A ...
- Fast Matrix Operations(UVA)11992
UVA 11992 - Fast Matrix Operations 给定一个r*c(r<=20,r*c<=1e6)的矩阵,其元素都是0,现在对其子矩阵进行操作. 1 x1 y1 x2 y ...
- Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- [LeetCode] Factor Combinations 因子组合
Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4. Write a func ...
- [LeetCode] Combinations 组合项
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
随机推荐
- JS-运动基础(一)续
2.淡入淡出的图片 用变量存储透明度 <title>无标题文档</title> <style> #div1{width:293px; height:220px; b ...
- HDU 5833 (2016大学生网络预选赛) Zhu and 772002(高斯消元求齐次方程的秩)
网络预选赛的题目……比赛的时候没有做上,确实是没啥思路,只知道肯定是整数分解,然后乘起来素数的幂肯定是偶数,然后就不知道该怎么办了… 最后题目要求输出方案数,首先根据题目应该能写出如下齐次方程(从别人 ...
- cocos2d3.8.1 使用prebuild提升发布android速度
1.生成cocos prebuild库 cocos gen-libs -m debug或 cocos gen-libs -m release 2.使用命令创建test项目 cocos new test ...
- C++:new 和 delete
在 C++ 中 , 使用 new 操作符动态申请内存的时候,如果申请失败,则会抛出 bad_alloc异常 当使用 delete 释放一块内存的时候 , 有些编译器上delete 不能判断一块内存 ...
- $.ajax和$.post的区别(前者根据key-value/后者根据形参)
post不需要给key-value形式: $("#btn").click(function(){ var url=basePath+"/emp/login"; ...
- Android ---paint类
引自:http://www.cnblogs.com/-OYK/archive/2011/10/25/2223624.html Android Paint和Color类 要绘图,首先得调整画笔,待画 ...
- [转]httpclient 上传文件、下载文件
用httpclient4.3 post方式推送文件到服务端 准备:httpclient-4.3.3.jar:httpcore-4.3.2.jar:httpmime-4.3.3.jar/** * 上传 ...
- Python3基础 定义无参数无返回值函数 调用会输出hello world的函数
镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...
- pscs6
http://wenku.baidu.com/link?url=cO03xdo_GQDdFdeYTDD36ZrjeHarUu4IN-fSEoFAnDXmd5W0yKvzkNWY_vOKKIaKbCdB ...
- HDU 5171 GTY's birthday gift 矩阵快速幂
GTY's birthday gift Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...