默默敲了一个下午,终于过了, 题目传送门 扩展Lucas是什么,就是对于模数p,p不是质数,但是不大,如果是1e9这种大数,可能没办法, 对于1000000之内的数是可以轻松解决的. 题解传送门 代码完全手写,直接写了扩展的中国剩余定理(普通的不会写) 题意:给你n,m,p 求C(n,m)%p #include<cstring> #include<cmath> #include<cstdio> #include<iostream> #include<a…
传送门 [题意]: 求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 Lucas定理P不是质数裸题 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; inline ll read(){ ,f=; ;c=get…
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…
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…
[题外话:我......不补了......] 2015 ICL, Finals, Div. 2:http://codeforces.com/gym/100637 G. #TheDress[水] (strstr函数真好用......) 代码: #include<bits/stdc++.h> using namespace std; ]; int main() { int n, i; scanf("%d ", &n); , y = , z = ;//地球人,外星人,其他…
http://codeforces.com/gym/100633/problem/J 其实这个解法不难学的,不需要太多的数学.但是证明的话,我可能给不了严格的证明.可以看看这篇文章 http://www.cnblogs.com/jianglangcaijin/p/3446839.html   膜拜 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include…
Java高并发 -- J.U.C.组件扩展 主要是学习慕课网实战视频<Java并发编程入门与高并发面试>的笔记 FutureTask Future模式,核心思想是异步调用.和同步调用的区别在于:如果某个任务A非常耗时,异步调用下,被调者可以立即返回,然后着手处理其他任务,不用在这个任务A上等待.等到真正需要任务A的结果了再尝试去获取. Future模式,有点类似淘宝购物,假如买一部手机,从付款到收到货可能需要三天,这三天不需要傻傻等待,因为付款后会有一个订单,而这个订单是我买了这件东西.可以凭…
Description 题库链接 求 \[C_n^m \mod p\] \(1\leq m\leq n\leq 10^{18},2\leq p\leq 1000000\) Solution 一般的 \(Lucas\) 是在模数 \(p\) 是质数的条件下适用的.我们来考虑 \(p\) 不是质数的条件. 我们对 \(p\) 进行唯一分解,记 \(p=p_1^{k_1}p_2^{k_2}\cdots p_q^{k_q}\) ,由于形同 \(p_i^{k_i}\) 的部分是互质的,显然我们可以用 \(…