组合数取模(逆元+快速幂)

博客介绍了如何在模意义下计算组合数C(n, m),强调了除法求模的正确方法,即使用逆元和快速幂。通过费马小定理确定B关于P的逆元,并利用数学排列组合公式C(n, m) = n! / (m! * (n-m)!), 提供了解决此类问题的代码实现。" 120479480,11397511,matplotlib绘制统计图:散点图、直方图与条形图解析,"['数据可视化', 'Python', 'matplotlib', '机器学习', '统计图表']
摘要由CSDN通过智能技术生成
Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu
 
LightOJ 1067
 

Description
Given n different objects, you want to take k of them. How many ways to can do it?
For example, say there are 4 items; you want to take 2 of them. So, you can do it 6 ways.
Take 1, 2
Take 1, 3
Take 1, 4
Take 2, 3
Take 2, 4
Take 3, 4

Input
Input starts with an integer T (≤ 2000), denoting the number of test cases.

Each test case contains two integers n (1 ≤ n ≤ 106), k (0 ≤ k ≤ n).


Output
For each case, output the case number and the desired value. Since the result can be very large, y
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值