求组合数

如果求C5 3 就是5*4*3/3*2*1 也就是(5/3)*(4/2)*(3/1)

Sample Input
5 //T
3 2 //C3 2
5 3
4 4
3 6
8 0

Sample Output
3
10
1
0
1

 # include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <cmath>
# define LL long long
using namespace std ; double fun(LL n,LL m)//返回类型必须是浮点型,不然会造成误差
{
LL i,j ;
double a=1.0,b=1.0;
double sum = 1.0;
j = m;
while(j--)
{
a=n;
b=m;
sum=sum*a/b; //约分
n--;
m--;
}
return sum;
} int main ()
{
//freopen("in.txt","r",stdin) ;
int T ;
scanf("%d" , &T) ;
while(T--)
{
int n , m ;
cin>>n>>m ;
if (n < m)
{
printf("0\n") ;
continue ;
}
printf("%.0lf\n" , fun(n,m)) ; } return ;
}

hdu 2519 求组合数的更多相关文章

  1. HDU 5852 Intersection is not allowed!(LGV定理行列式求组合数)题解

    题意:有K个棋子在一个大小为N×N的棋盘.一开始,它们都在棋盘的顶端,它们起始的位置是 (1,a1),(1,a2),...,(1,ak) ,它们的目的地是 (n,b1),(n,b2),...,(n,b ...

  2. HDU 5698——瞬间移动——————【逆元求组合数】

    瞬间移动 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submis ...

  3. 数学--数论--HDU 4675 GCD of Sequence(莫比乌斯反演+卢卡斯定理求组合数+乘法逆元+快速幂取模)

    先放知识点: 莫比乌斯反演 卢卡斯定理求组合数 乘法逆元 快速幂取模 GCD of Sequence Alice is playing a game with Bob. Alice shows N i ...

  4. lucas求组合数C(n,k)%p

    Saving Beans http://acm.hdu.edu.cn/showproblem.php?pid=3037 #include<cstdio> typedef __int64 L ...

  5. URAL 1994 The Emperor's plan 求组合数 大数用log+exp处理

    URAL 1994 The Emperor's plan 求组合数 大数用log #include<functional> #include<algorithm> #inclu ...

  6. N!分解质因子p的个数_快速求组合数C(n,m)

    int f(int n,int p) { ) ; return f(n/p,p) + n/p; } https://www.xuebuyuan.com/2867209.html 求组合数C(n,m)( ...

  7. 求组合数、求逆元、求阶乘 O(n)

    在O(n)的时间内求组合数.求逆元.求阶乘.·.· #include <iostream> #include <cstdio> #define ll long long ;// ...

  8. 求组合数 C++程序

    一 递归求组合数 设函数为void    comb(int m,int k)为找出从自然数1.2.... .m中任取k个数的所有组合. 分析:当组合的第一个数字选定时,其后的数字是从余下的m-1个数中 ...

  9. Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 【逆元求组合数 && 离散化】

    任意门:http://codeforces.com/contest/689/problem/E E. Mike and Geometry Problem time limit per test 3 s ...

随机推荐

  1. 04.基于IDEA+Spring+Maven搭建测试项目--application-context.xml配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  2. Could not resolve placeholder 'jdbc.driver'

     将jdbc.driver=oracle.jdbc.OracleDriver 改成jdbc.driver=oracle.jdbc.driver.OracleDriver     或者反过来修改.    ...

  3. luogu1082 [NOIp2012]同余方程 (扩展欧几里得)

    由于保证有解,所以1%gcd(x,y)=0,所以gcd(x,y)=1,直接做就行了 #include<bits/stdc++.h> #define pa pair<int,int&g ...

  4. 解题:SHOI 2014 概率充电器

    题面 显然就是在求概率,因为期望乘的全是1....然后就推推推啊 设$fgg[i]$表示这个点父亲没给他充上电的概率,$sgg[i]$表示这个点子树(和它自己)没给他充上电的概率,然后这个点没充上电的 ...

  5. Tomcat权威指南-读书摘要系列8

    调试与疑难排查 解读日志文件 /conf/logging-properties 用RequestDumperValue来调试 查看Web通信流量 server.xml <Valve classN ...

  6. Easy2Boot-小清新教程

    Author:KillerLegend Date:2014.8.14 From:http://www.cnblogs.com/killerlegend/p/3913614.html 之所以说是小清新, ...

  7. SSM数据库数据导出excel

    首先,这是我对自己的需求而使用的逻辑,若有可以完美的地方方便告诉下小白. apache的poi MAVEN <dependency> <groupId>org.apache.p ...

  8. 2-SAT问题的方案输出

    2-sat 推荐学习资料: 伍昱的2003年IOI国家集训队论文<由对称性解2-sat问题> 论文链接:https://wenku.baidu.com/view/31fd7200bed5b ...

  9. Nginx学习总结

    2017年2月23日, 星期四 Nginx学习总结 Nginx是目前比较主流的HTTP反向代理服务器(其企业版提供了基于TCP层的反向代理插件),对于构建大型分布式web应用,具有举足轻重的作用.简单 ...

  10. 用Emacs将文件加密保存

    为Emacs安装ps-ccrypt插件. 如果你在使用elpa(Emacs的一个插件管理器), 可以M-x list-packages, 从插件列表中找到 ps-ccrypt, 在该项上按i将其标记为 ...