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…
题目链接 ->扩展Lucas //求C_n^k%m #include <cstdio> typedef long long LL; LL FP(LL x,LL k,LL p) { LL t=1ll; for(; k; k>>=1,x=x*x%p) if(k&1) t=t*x%p; return t; } void Exgcd(LL a,LL b,LL &x,LL &y) { if(!b) x=1ll, y=0ll; else Exgcd(b,a%b,y…
默默敲了一个下午,终于过了, 题目传送门 扩展Lucas是什么,就是对于模数p,p不是质数,但是不大,如果是1e9这种大数,可能没办法, 对于1000000之内的数是可以轻松解决的. 题解传送门 代码完全手写,直接写了扩展的中国剩余定理(普通的不会写) 题意:给你n,m,p 求C(n,m)%p #include<cstring> #include<cmath> #include<cstdio> #include<iostream> #include<a…
题目: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的倍数 和 其余部分 分开…
J. Ceizenpok’s formula time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dr. Ceizenp'ok from planet i1c5l became famous across the whole Universe thanks to his recent discovery — the Ceizenp…
传送门 [题意]: 求C(n,k)%m,n<=108,k<=n,m<=106 [思路]: 扩展lucas定理+中国剩余定理    #include<cstdio> using namespace std; typedef long long ll; ll n,m,MOD,ans; ll fpow(ll a,ll p,ll mod){ ll res=; ,a=a*a%mod) ) res=res*a%mod; return res; } void exgcd(ll a,ll b…
http://codeforces.com/gym/100633/problem/J 其实这个解法不难学的,不需要太多的数学.但是证明的话,我可能给不了严格的证明.可以看看这篇文章 http://www.cnblogs.com/jianglangcaijin/p/3446839.html   膜拜 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include…
再次感谢zyf2000超强的讲解. 扩展CRT其实就是爆推式子,然后一路合并,只是最后一个式子上我有点小疑惑,但整体还算好理解. #include<iostream> #include<cstdio> #include<queue> #include<map> #include<algorithm> #include<vector> #include<bitset> #include<set> #include…
可以先做这个题[SDOI2010]古代猪文 此算法和LUCAS定理没有半毛钱关系. [模板]扩展卢卡斯 不保证P是质数. $C_n^m=\frac{n!}{m!(n-m)!}$ 麻烦的是分母. 如果互质就有逆元了. 所以可以考虑把分子分母不互质的数单独提出来处理. 然鹅P太一般,直接处理要考虑的东西太多. 我们不妨令$p=p_1^{q_1}*p_2^{q_2}*...*p_k^{q_k}$ 对每一个$p_i^{q_i}$分别求解(不妨叫这个数为$pk$)(这样会容易很多) 即求ai满足:$\fr…
扩展Lucas定理模板题(貌似这玩意也只能出模板题了吧~~本菜鸡见识鄙薄,有待指正) 原理: https://blog.csdn.net/hqddm1253679098/article/details/82897638 https://blog.csdn.net/clove_unique/article/details/54571216 感觉扩展Lucas定理和Lucas定理的复杂程度差了不止一个档次,用到了一大堆莫名其妙的函数. 另外谁能告诉我把一个很大的组合数对一个非质数取模有什么卵用 #i…