#include<bits/stdc++.h> using namespace std; typedef long long ll; const int a[4]={2,3,4679,35617}; int p[36000],b[4],n,g,ans,i,j,x,y,mod=999911658; int power(int a,int b){//快速幂 int c=1; for(;b;b>>=1){ if(b&1) c=(ll)c*a%mod; a=(ll)a*a%mod;…
typedef long long ll; /********************************** 大组合数取模之lucas定理模板,1<=n<=m<=1e9,1<p<=1e6,p必须为素数 输入:C(n,m)%p 调用lucas(n,m,p) 复杂度:min(m,p)*log(m) ***********************************/ //ax + by = gcd(a,b) //传入固定值a,b.放回 d=gcd(a,b), x , y…
#include<bits/stdc++.h> #define re register #define int long long using namespace std; ; inline int read(){ re ,b=;re char ch=getchar(); ') b=(ch==:,ch=getchar(); ') a=(a<<)+(a<<)+(ch^),ch=getchar(); return a*b; } inline int qpow(re int…
题集链接: https://cn.vjudge.net/contest/231988 解题之前请先了解组合数取模和Lucas定理 A : FZU-2020 输出组合数C(n, m) mod p (1 <= m <= n <= 10^9, m <= 10^4, m < p < 10^9, p是素数) 由于p较大,不可以打表,直接Lucas求解 #include<iostream> using namespace std; typedef long long…
DP? Problem Description Figure 1 shows the Yang Hui Triangle. We number the row from top to bottom 0,1,2,…and the column from left to right 0,1,2,….If using C(n,k) represents the number of row n, column k. The Yang Hui Triangle has a regular pattern…
LL MyPow(LL a, LL b) { LL ret = ; while (b) { ) ret = ret * a % MOD; a = a * a % MOD; b >>= ; } return ret; } LL C(int n, int m) { ) ; LL a = fact[n], b = fact[n - m] * fact[m] % MOD; ) % MOD;//除以一个数,等于乘以这个数的乘法逆元, 然后是在MOD的情况下 } 上面的代码可以计算组合数取模, 能解决的规…
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…