数学
magic_sheep
这个作者很懒,什么都没留下…
展开
-
BZOJ 4517 [Sdoi2016]排列计数
裸的错排公式,组合数用乘法逆元解决。 补一下错排公式 :D(n) = (n-1) [D(n-2) + D(n-1)]/************************************************************** Problem: 4517 User: vermouth Language: C++ Result: Accepted原创 2017-02-28 20:55:17 · 289 阅读 · 0 评论 -
BZOJ 2440 完全平方数 莫比乌斯函数应用
线性筛求莫比乌斯函数练手题,具体见代码。#include<cstdio> #include<iostream> #include<cstring> #include<cmath> #define ll long long using namespace std; const int maxn=500000; int mu[maxn],prime[maxn],tot; bool mark[maxn]原创 2017-02-28 21:56:06 · 220 阅读 · 0 评论 -
BZOJ 2982 combination
lucas定理裸题,表达式:C(n,m)%p=C(n/p,m/p)*C(n%p,m%p)%p 由于p为素数 根据费马小定理: 已知(a, p) = 1,则 a^p-1 ≡ 1 (mod p), 所以 a*a^p-2 ≡ 1 (mod p)。 也就是 (m!(n-m)!)的逆元为 (m!(n-m)!)^p-2#include<cstdio> #include<iostream> #defi原创 2017-03-16 21:24:06 · 371 阅读 · 0 评论