随笔分类 - 数学
摘要:组合数取模: 求1e18范围的组合数取模: 卢卡斯定理: \(\tbinom{m}{n} \equiv \tbinom{m\mod p}{n\mod p}\tbinom{m/p}{n/p}\mod p\) 求$i\mod p$逆元: 解不定方程组$i(inv)+py = gcd(i, p)=1$ c
阅读全文
摘要:实现了进制转换的简单算法(仅限正整数). #include<cstdio> inline int power(int x, int p) { int b = 1; while (p) { if (p & 1) b *= x; p >>= 1; x *= x; } return b; } inline
阅读全文
摘要:Cantor Expansion: \(X = \sum_{i=1}^n (n-i)!\sum_{j=i+1}^{n}[p_i>p_j]\) It is a bijection from a permutation of \(p[1..n]\) to its dictionary order. We
阅读全文
摘要:Link:https://codeforces.com/problemset/problem/1492/B description: You are given a deck of cards, numbered from \(1\) to \(n\). For each time you can
阅读全文
摘要:description: How many pairs \(<a,b>\), s.t. \(a\mod b=\lfloor\frac{a}{b}\rfloor\), for \(1\leqslant a\leqslant x\), $1\leqslant b\leqslant y $ ? solut
阅读全文
摘要:Link:https://codeforces.com/problemset/problem/1487/D description: Find the numbers of triples$(a,b,c)$s.t.$a2+b2=c^2$and \(a^2=b+c\), where 1≤a≤b≤c≤n
阅读全文
摘要:n阶$Farey Sequence$是 [0,1]间 分母不超过n的有理数的升序排列. 相关数学证明: \(\frac{m}{n}<\frac{m+m'}{n+n'}<\frac{m'}{n'}\) 初始, 令$\frac{0}{1} = \frac$, \(\frac{1}{1} = \frac{
阅读全文
摘要:discription: 判断一个图是否为欧拉图(图本身是欧拉闭迹) 欧拉闭迹的定义:含有图中每一条边的闭合迹(trail). 迹(trail)的定义:一条没有重复边的途径(walk) 途径(walk)的定义:形如{\(x_0,x_1\)},{\(x_1,x_2\)},{\(x_2,x_3\)},.
阅读全文
摘要:计算$\pi(x)和打质数表$ code: #include<cstdio> #include<vector> using std::vector; int seive(vector<int>& prime, const int& x) { bool* A = new bool[x + 1]; fo
阅读全文
摘要:Concrete破百页纪念. 没啥好说的, 无情上公式. \(gcd(0,n)=n\) \(gcd(m,n)=gcd(n\ mod\ m, m)\) \(ax+by=gcd(a,b)\) \(If\ a=0, we\ have\ x=0,y=1\) \(otherwise, let\ r=b\ mo
阅读全文
摘要:牛顿迭代法解方程: \(f(x)=0\) 将$f$泰勒展开一阶,得到: \(f(x)=f(x_0)+f'(x_0)(x-x_0)+o(x-x_0)\) 令 \(f(x_0)+f'(x_0)(x-x_0)=0\) \(x=x_0-\frac{f(x_0)}{f'(x_0)}\) 当初值取得合理, 如果
阅读全文