您的位置:首页 > 其它

UVa 369 - Combinations

2013-10-01 18:39 302 查看
  题目大意:给两个数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
.divide(fact[m]).divide(fact[n-m]);
System.out.println(n + " things taken " + m + " at a time is " + ans + " exactly.");
}

}
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: