传送门

貌似就是lucas的板子题啊。

练一练手感觉挺舒服的^_^

代码:

#include<bits/stdc++.h>
#define mod 10007
#define ll long long
using namespace std;
int T_T;
ll n,m,fac[mod+5],ifac[mod+5];
inline ll lucas(ll a,ll b){
    if(a<b)return 0;
    if(a<mod&&b<mod)return fac[a]*ifac[b]%mod*ifac[a-b]%mod;
    return lucas(a%mod,b%mod)*lucas(a/mod,b/mod)%mod;
}
int main(){
    scanf("%d",&T_T),fac[0]=1,ifac[1]=ifac[0]=1;
    for(ll i=1;i<mod;++i)fac[i]=fac[i-1]*i%mod;
    for(ll i=2;i<mod;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;
    for(ll i=2;i<mod;++i)(ifac[i]*=ifac[i-1])%=mod;
    while(T_T--)scanf("%lld%lld",&n,&m),printf("%lld\n",lucas(n,m));
    return 0;
}

2018.09.14 bzoj2982: combination(Lucas定理)的更多相关文章

  1. bzoj2982: combination(lucas定理板子)

    2982: combination Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 664  Solved: 397[Submit][Status][Di ...

  2. [BZOJ2982]combination Lucas定理

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2982 $C(N,M)\% P = C(N\% P,M\% P) * C(N/P,M/P)\ ...

  3. 【BZOJ2982】combination Lucas定理

    [BZOJ2982]combination Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然, ...

  4. ZOJ 3557 & BZOJ 2982 combination[Lucas定理]

    How Many Sets II Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a set S = {1, 2, ..., n}, n ...

  5. BZOJ2982: combination Lucas模板

    2982: combination Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 734  Solved: 437[Submit][Status][Di ...

  6. bzoj2982 combination——卢卡斯定理

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2982 卢卡斯定理裸题: 原准备1A来着,结果输出忘了加回车! 预处理阶乘或者现求都可以,感觉 ...

  7. BZOJ2982: combination Lucas

    Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然,LMZ的一年有10007天,所以他想知道答案 ...

  8. BZOJ 2982 combination Lucas定理

    题目大意:发上来就过不了审核了--总之大意就是求C(n,m) mod 10007 m,n∈[1,2*10^8] 卢卡斯定理:C(n,m)=C(n%p,m%p)*C(n/p,m/p) mod p 要求p ...

  9. 2018.09.14 洛谷P3931 SAC E#1 - 一道难题 Tree(树形dp)

    传送门 简单dp题. f[i]表示以i为根的子树被割掉的最小值. 那么有: f[i]=min(∑vf[v],dist(i,fa))" role="presentation" ...

随机推荐

  1. LiveBinding应用 dataBind 数据绑定

    http://blog.csdn.net/embarcaderochina/article/details/50352193 firemonkey grid/listview dataBind,数据绑 ...

  2. Gson 解析教程

    Gson 是google解析Json的一个开源框架,同类的框架fastJson,JackJson等等 本人fastJson用了两年,也是从去年才开始接触Gson,希望下面的总结会对博友有用,至于Gso ...

  3. a 超链接标签

    Title百度 第一章 第一章 第一章内容 第二章内容 <!DOCTYPE html><html lang="en"><head> <me ...

  4. canal 常用配置

    https://github.com/alibaba/canal/wiki/AdminGuide canal.instance.filter.regex 监控哪些表的正则配置 如下: mysql 数据 ...

  5. Mysql 主- 开启binlog

    https://www.cnblogs.com/martinzhang/p/3454358.html my.cnf 添加 log_bin=mysql-bin 开启日志,然后重启mysql服务器. 查看 ...

  6. Eclipse 工程使用相对路径导入Jar包设置

    环境:MyEclipse 6.5 问题:MyEclipse 工程使用相对路径导入Jar包 我们在导入工程时,往往添加Jar都是使用的绝对路径,但这带来了一个问题,不同的用户使用工程都得重新配置Buil ...

  7. Linux下类似windows下_beginthread和_endthread 的多线程开发

    在 windows下头文件中包含 #include<process.h> 就可以使用_beginthread进行线程创建.个人感觉挺方便的. 在linux下类似于_beginthread ...

  8. 泛型集合与DataSet相互转换

    一.泛型转DataSet /// <summary> /// 泛型集合转换DataSet /// </summary> /// <typeparam name=" ...

  9. mongodb基础学习3-查询的复杂用法

    昨天看了一下查询,今天来说下查询的复杂用法,可以类比mysql的查询 $ne:不等于 $gt, $gte, $lt, $lte:大于,大于等于,小于,小于等于 $in $and $nor:相当于上面的 ...

  10. map模块使用方法

    map指令使用ngx_http_map_module模块提供的.默认情况下,nginx有加载这个模块,除非人为的 --without-http_map_module.ngx_http_map_modu ...