题意:求C(n,m)

n,m<=200000000

思路:c(n,m)=c(n mod mo,m mod mo)*c(n div mo,m div mo) mod mo (n>=mo或m>=mo)

c(x,y)=0 (x<y)

c(n,m)=fac[n]*exf[m]*exf[n-m] (n,m<mo)

 const mo=;
var exf,fac:array[..]of longint;
n,i,x,y:longint; function c(n,m:longint):longint;
begin
if n<m then exit();
if (n<mo)and(m<mo) then exit(fac[n]*exf[m] mod mo*exf[n-m] mod mo);
exit(c(n mod mo,m mod mo)*c(n div mo,m div mo) mod mo);
end; begin
assign(input,'bzoj2982.in'); reset(input);
assign(output,'bzoj2982.out'); rewrite(output);
readln(n);
exf[]:=; exf[]:=; fac[]:=; fac[]:=;
for i:= to do
begin
exf[i]:=exf[mo mod i]*(mo-mo div i) mod mo;
fac[i]:=fac[i-]*i mod mo;
end;
for i:= to do exf[i]:=exf[i-]*exf[i] mod mo; for i:= to n do
begin
readln(x,y);
writeln(c(x,y));
end;
close(input);
close(output);
end.

【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. Lucas定理模板【bzoj2982】【combination】

    (上不了p站我要死了,侵权度娘背锅) Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然,LMZ ...

  10. 【BZOJ】2982: combination(lucas定理+乘法逆元)

    http://www.lydsy.com/JudgeOnline/problem.php?id=2982 少加了特判n<m return 0就wa了QAQ lucas定理:C(n, m)%p=( ...

随机推荐

  1. AJPFX总结List的三个子类的特点

    ArrayList:                        底层数据结构是数组,查询快,增删慢.                        线程不安全,效率高.              ...

  2. git常用命令图解 & 常见错误

    Git 常用命令 基本命令 git clone.这是一种较为简单的初始化方式,当你已经有一个远程的Git版本库,只需要在本地克隆一份 git clone git://github.com/someon ...

  3. LN : leetcode 730 Count Different Palindromic Subsequences

    lc 730 Count Different Palindromic Subsequences 730 Count Different Palindromic Subsequences Given a ...

  4. [ Luogu 3709 ] 大爷的字符串题

    \(\\\) Description 原题题面太过混乱出题人语文凉凉 给出一个长为 \(n\) 的数列 \(A\) ,多次询问: 对于一个区间 \([L_i,R_i]\),把区间内的所有数最少划分成多 ...

  5. 全文索引Elasticsearch,Solr,Lucene

    最近项目组安排了一个任务,项目中用到了全文搜索,基于全文搜索 Solr,但是该 Solr 搜索云项目不稳定,经常查询不出来数据,需要手动全量同步,而且是其他团队在维护,依赖性太强,导致 Solr 服务 ...

  6. laravel学习笔记(一)

    laravel 简述 优点:优雅.简洁.工程化(项目架构,协同开发) 版本:2011 June 1.0 ,LTS(long time) ,laravel 5.4 功能:队列.搜索.数据库搜索.定时脚本 ...

  7. Summary of 2016 International Trusted Computing and Cloud Security Summit

    1)      Welcome Remarks 2)      The advancement of Cloud Computing and Tursted Computing national st ...

  8. Python3简明教程(二)—— 变量和数据类型

    关键字和标识符 下列的标识符是Python3的关键字,并且不能用于通常的标识符.关键字必须严格按照下面的拼写: False def if raise None del import return Tr ...

  9. sed替换字符串中的某些字符

    test.txt原文内容 http://jsldfjaslfjsldfjasl/test?jlsdfjsalfjslfd 使用sed替换 sed -ri 's/(http:\/\/)[^\/]*(\/ ...

  10. ios之coretext

    API接口文档. https://developer.apple.com/library/mac/#documentation/Carbon/Reference/CoreText_Framework_ ...