lucas模板
ll PowMod(ll a,ll b,ll MOD){
ll ret=;
while(b){
if(b&) ret=(ret*a)%MOD;
a=(a*a)%MOD;
b>>=;
}
return ret;
}
ll fac[];
ll Get_Fact(ll p)
{
fac[]=;
for(int i=;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;
if(a<b) return ;
ret=(ret*fac[a]*PowMod(fac[b]*fac[a-b]%p,p-,p))%p;
n/=p;
m/=p;
}
return ret;
}
lucas模板的更多相关文章
- BZOJ2982: combination Lucas模板
2982: combination Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 734 Solved: 437[Submit][Status][Di ...
- lucas 模板 洛古模板题
#include<bits/stdc++.h> #define int long long using namespace std; ; int a[maxn]; int quick(in ...
- bzoj 2142 礼物——扩展lucas模板
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2142 没给P的范围,但说 pi ^ ci<=1e5,一看就是扩展lucas. 学习材料 ...
- bzoj 2982 combination——lucas模板
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2982 明明是lucas定理裸题…… 非常需要注意C( )里 if ( n<m ) r ...
- BZOJ 2982: combination Lucas模板题
Code: #include<bits/stdc++.h> #define ll long long #define maxn 1000003 using namespace std; c ...
- 排列组合lucas模板
//codeforces 559C|51nod1486 Gerald and Giant Chess(组合数学+逆元) #include <bits/stdc++.h> using nam ...
- GYM100633J. Ceizenpok’s formula 扩展lucas模板
J. Ceizenpok’s formula time limit per test 2.0 s memory limit per test 256 MB input standard input o ...
- Lucas模板&快速幂模板
/* *********************************************** Author :guanjun Created Time :2016/5/20 0:28:36 F ...
- Lucas定理模板【bzoj2982】【combination】
(上不了p站我要死了,侵权度娘背锅) Description LMZ有n个不同的基友,他每天晚上要选m个进行[河蟹],而且要求每天晚上的选择都不一样.那么LMZ能够持续多少个这样的夜晚呢?当然,LMZ ...
随机推荐
- UVA 11111-Generalized Matrioshkas(栈)
题意:有很多层盒子,盒子里面再套盒子,一个盒子可能套多个独立的子盒子,但子盒子的总体积必须小于该盒子,否则不合法,输入给一行数,负数代表左边,正数代表右边,大小表示其体积,如-2,-1,1,2则表示体 ...
- python刷取CSDN博文访问量之四
python刷取CSDN博文访问量之四 作者:vpoet #coding:utf-8 import requests import urllib2 import re import time def ...
- HDU 3634 City Planning (离散化)
City Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- Number of Containers(数学) 分类: 数学 2015-07-07 23:42 1人阅读 评论(0) 收藏
Number of Containers Time Limit: 1 Second Memory Limit: 32768 KB For two integers m and k, k is said ...
- 【转】android camera(三):camera V4L2 FIMC
关键词:android camera CMM 模组 camera参数 CAMIF V4L2 平台信息:内核:linux系统:android 平台:S5PV310(samsung exynos ...
- SqlServer 数据库日志无法收缩处理过程
今天按常用方法收缩一个测试用的数据库日志,发现没法收缩! dbcc sqlperf(logspace) USE [dbname] GO ALTER DATABASE [dbname] SET ...
- ID(dfs+bfs)-hdu-4127-Flood-it!
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4127 题目意思: 给n*n的方格,每个格子有一种颜色(0~5),每次可以选择一种颜色,使得和左上角相 ...
- Unity 梯子生成算法
Unity之生成梯子算法的实现. 1.通过预制物体动态生成角度可设置的梯子形状. 1.1 主要涉及到的数学知识点,角度与弧度的转化. 弧度=角度乘以π后再除以180 角度=弧度除以π再乘以180 1. ...
- C# 调用存储过程传入表变量作为参数
首先在SQLServer定义一个自定义表类型: USE [ABC] GO CREATE TYPE [ABC].[MyCustomType] AS TABLE( ) NOT NULL, ) NULL, ...
- android XML解析之DOM解析方式
DOM 解析方式步骤: 第一步:首选需要获得DOM解析器工厂实例 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance ...