bzoj2982: combination(lucas定理板子)】的更多相关文章

2982: combination Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 664  Solved: 397[Submit][Status][Discuss] Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然,LMZ的一年有10007天,所以他想知道答案mod 10007的值.(1<=m<=n<=200,000,000) Inpu…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2982 $C(N,M)\% P = C(N\% P,M\% P) * C(N/P,M/P)\% P$ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; ],fac[]; int C(int x,int y){ ; return fac[x]*inv[fac[y…
[BZOJ2982]combination Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然,LMZ的一年有10007天,所以他想知道答案mod 10007的值.(1<=m<=n<=200,000,000) Input   第一行一个整数t,表示有t组数据.(t<=200)   接下来t行每行两个整数n, m,如题意. Output T行,每行一个数,为C(n, m) mod…
How Many Sets II Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a set S = {1, 2, ..., n}, number m and p, your job is to count how many set T satisfies the following condition: T is a subset of S |T| = m T does not contain continuous numbers…
2982: combination Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 734  Solved: 437[Submit][Status][Discuss] Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然,LMZ的一年有10007天,所以他想知道答案mod 10007的值.(1<=m<=n<=200,000,000) Inpu…
Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然,LMZ的一年有10007天,所以他想知道答案mod 10007的值.(1<=m<=n<=200,000,000) Input   第一行一个整数t,表示有t组数据.(t<=200)   接下来t行每行两个整数n, m,如题意. Output T行,每行一个数,为C(n, m) mod 10007的答案. Sample Input…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2982 卢卡斯定理裸题: 原准备1A来着,结果输出忘了加回车! 预处理阶乘或者现求都可以,感觉学到了一种现求 C 的写法呢. 代码如下: #include<iostream> #include<cstdio> #include<cstring> using namespace std; typedef long long ll; ; ll fac[]; void i…
题目大意:发上来就过不了审核了--总之大意就是求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是质数 当中n%p可能会小于m%p 这样的情况下直接返回0就可以 证明去问卢卡斯 我不知道 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define p 1…
传送门 貌似就是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 fa…
(上不了p站我要死了,侵权度娘背锅) Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然,LMZ的一年有10007天,所以他想知道答案mod 10007的值.(1<=m<=n<=200,000,000) Input 第一行一个整数t,表示有t组数据.(t<=200) 接下来t行每行两个整数n, m,如题意. Output T行,每行一个数,为C(n, m) mod 10007的答…