lucas模板】的更多相关文章

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…
ll PowMod(ll a,ll b,ll MOD){ ll ret=; while(b){ ) ret=(ret*a)%MOD; a=(a*a)%MOD; b>>=; } return ret; } ll fac[]; ll Get_Fact(ll p) { fac[]=; ;i<=p;i++) fac[i]=(fac[i-]*i)%p; } ll Lucas(ll n,ll m,ll p){ ll ret=; while(n&&m){ ll a=n%p,b=m%p;…
#include<bits/stdc++.h> #define int long long using namespace std; ; int a[maxn]; int quick(int a,int n,int p) { ; while(n) { ) ans=ans%p*a%p; a=a%p*a%p; n>>=; } return ans%p; } int C(int x,int y,int p) // C(x,y); { ; a[]=; ;i<=p;i++) a[i]=…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2142 没给P的范围,但说 pi ^ ci<=1e5,一看就是扩展lucas. 学习材料:https://blog.csdn.net/clove_unique/article/details/54571216 https://www.cnblogs.com/elpsycongroo/p/7620197.html 于是打(抄)了第一份exlucas的板子.那个把 pi的倍数 和 其余部分 分开…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2982 明明是lucas定理裸题…… 非常需要注意C( )里  if ( n<m ) return 0; !!!!! 可以预处理阶乘和其逆元,也可以现求.现求阶乘逆元的话,可以把 jc[m] 和 jc[n-m] 乘起来再放到pw里. #include<iostream> #include<cstdio> #include<cstring> #define ll…
Code: #include<bits/stdc++.h> #define ll long long #define maxn 1000003 using namespace std; const ll mod = 10007; void setIO(string s) { string in=s+".in"; freopen(in.c_str(),"r",stdin); } struct Comb { ll fac[maxn]; ll qpow(ll…
//codeforces 559C|51nod1486 Gerald and Giant Chess(组合数学+逆元) #include <bits/stdc++.h> using namespace std; #define LL long long typedef pair<int,int> pii; const int inf = 0x3f3f3f3f; ; #define clc(a,b) memset(a,b,sizeof(a)) ; ; void fre() {freo…
J. Ceizenpok’s formula time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output Dr. Ceizenp'ok from planet i1c5l became famous across the whole Universe thanks to his recent discovery — the Ceizenpok’s formul…
/* *********************************************** Author :guanjun Created Time :2016/5/20 0:28:36 File Name :hdu5698.cpp ************************************************ */ #include <iostream> #include <cstdlib> #include <stdio.h> #incl…
(上不了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的答…