随笔 - 530  文章 - 0  评论 - 3  阅读 - 10098 

随笔分类 -  数学

求逆矩阵
摘要:void inv(mat &x){ int n = 2, is[2], js[2]; memset(is, 0, sizeof(is)); memset(js, 0, sizeof(js)); for (int k = 0; k < n; k++) { for (int i = k, j; i < 阅读全文
posted @ 2023-12-23 00:26 towboat 阅读(6) 评论(0) 推荐(0) 编辑
求1~n的逆元
摘要:void init(int top){ inv[1] =1 ; for(int i=2;i<=top;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod; } 阅读全文
posted @ 2023-12-17 18:26 towboat 阅读(5) 评论(0) 推荐(0) 编辑
POJ 2417
摘要:求解 a^x≡b (mod c) ( x<c ) siz = sqrt( c ) a^( i*siz + j) ≡b (mod c) a^j ≡ a^( - i* siz) *b (mod c) 枚举 j , 将 (j, a^j %c ) 存入map ; 枚举 i, 查询map的值 ( a^(-i 阅读全文
posted @ 2023-07-02 16:46 towboat 阅读(5) 评论(0) 推荐(0) 编辑
裴蜀定理 记录
摘要:def. 对任意(a,b) , 存在x,y, 满足 ax+by= gcd(a,b) > ax+by 一定是gcd(a,b) 的倍数 阅读全文
posted @ 2023-07-01 20:35 towboat 阅读(4) 评论(0) 推荐(0) 编辑
P4071 [SDOI2016]排列计数
摘要:错位排列板子题,plus: 组合数取模 const int N=1e6; #define int long long const int mod =1e9+7 ; int n,m,D[N+3] ; #define ll long long ll inv[N+3]; int F[N+3] ; int 阅读全文
posted @ 2023-05-06 14:23 towboat 阅读(11) 评论(0) 推荐(0) 编辑
关于组合数的补充
摘要:https://baijiahao.baidu.com/s?id=1614495972671761444&wfr=spider&for=pc 阅读全文
posted @ 2023-05-02 00:09 towboat 阅读(16) 评论(0) 推荐(0) 编辑
Fib数列的递推
摘要:矩阵快速幂 #include <iostream> #include <cmath> #include <algorithm> using namespace std; #define N 2 int mod; #define int long long struct matrix { int a[ 阅读全文
posted @ 2023-04-30 18:18 towboat 阅读(17) 评论(0) 推荐(0) 编辑
Series-Parallel Networks UVA - 10253
摘要:给定 n,求有多少树满足:任意非叶子节点的儿子不少于 2 , 叶子节点个数为 n 阅读全文
posted @ 2023-04-29 12:31 towboat 阅读(8) 评论(0) 推荐(0) 编辑
Marbles UVA - 10090
摘要:给定两种购买物品的方案:花费 c1元购买 n1 个物品,或者花费 c2c2​ 元购买 n2n2​ 个物品。 方案可以无限使用,询问购买 n个物品至少要多少元,若无法恰好购买到 n 个物品输出 failed #include <iostream> #include <algorithm> #inclu 阅读全文
posted @ 2023-04-26 21:35 towboat 阅读(26) 评论(0) 推荐(0) 编辑
P1495 【模板】中国剩余定理(CRT)/ 曹冲养猪
摘要:#include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; #define int long long int n,a[20],M[20],Mi[20]; int 阅读全文
posted @ 2023-04-26 18:33 towboat 阅读(3) 评论(0) 推荐(0) 编辑
Hyper-drive UVA - 10542
摘要:题意:给定一些个d维的方块,给定两点,求穿过多少方块 转化为(0,0) 到 (a,b) 先考虑二维的 然后容斥原理 #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace 阅读全文
posted @ 2023-04-26 15:16 towboat 阅读(8) 评论(0) 推荐(0) 编辑
Prime Distance UVA - 10140
摘要:定两个整数 L,R , 求闭区间 [L,R] 中相邻两个质数差值最小的数对与差值最大的数对。 当存在多个时,输出靠前的素数对。 筛 1e6 每个素数,在区间里标记倍数, 类似的还有 https://www.luogu.com.cn/problem/P1835 #include<iostream> # 阅读全文
posted @ 2023-04-24 15:58 towboat 阅读(26) 评论(0) 推荐(0) 编辑
Prime k-tuple UVA - 1404
摘要:一个步骤: 在[ a, b] 中标记 S 的倍数 #include<iostream> #include<cstring> #include<algorithm> #include<vector> using namespace std; const int N=1e5+20; const int 阅读全文
posted @ 2023-04-24 13:56 towboat 阅读(14) 评论(0) 推荐(0) 编辑
The Bells are Ringing UVA-12119
摘要:已知M 为T1,T2,T3 的LCM 输出满足 Ti-Tj<=25 的所有可能情况 #include<iostream> #include<cmath> #include<algorithm> #include<cstring> using namespace std; const int N= 1 阅读全文
posted @ 2023-04-23 23:29 towboat 阅读(22) 评论(0) 推荐(0) 编辑
UVA11014
摘要:给定一个NxNxN的正方体,求出最多能选几个整数点。使得随意两点PQ不会使PQO共线。 F(k) #include<iostream> #include<cmath> #include<algorithm> using namespace std; const int N=5e5; #define 阅读全文
posted @ 2023-04-23 19:43 towboat 阅读(8) 评论(0) 推荐(0) 编辑
Gauss Prime UVA - 1415
摘要:#include<iostream> #include<cstring> #include<algorithm> using namespace std; const int N=5e4; int b[N+2], pm[N+2],tot=0; void init(){ b[1]=1; for(int 阅读全文
posted @ 2023-04-23 17:48 towboat 阅读(10) 评论(0) 推荐(0) 编辑
组合数取模
摘要:const int N =1e5+4; int fac[N] ,fm[N]; inline int kpow(int a, int b) { int res = 1; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % m 阅读全文
posted @ 2023-04-21 16:56 towboat 阅读(284) 评论(0) 推荐(0) 编辑
Devu and Flowers CF451E
摘要:Devu 有 n 个花瓶,第 ii 个花瓶里有 fi 朵花。他现在要选择 s 朵花。 你需要求出有多少种方案。两种方案不同当且仅当两种方案中至少有一个花瓶选择花的数量不同 可重复集的组合数 Ce( n,m) = C(m-1,m+n-1 ) namo用容斥原理 #include<iostream> # 阅读全文
posted @ 2023-04-21 16:49 towboat 阅读(27) 评论(0) 推荐(0) 编辑
UVA10237 Bishops
摘要:#include <iostream> #include <cstring> #include <queue> using namespace std; const int N=2e5+2; #define int long long int n,m,f1[50][2000] ,f2[50][200 阅读全文
posted @ 2023-04-20 22:04 towboat 阅读(7) 评论(0) 推荐(0) 编辑
Arrange the Numbers UVA - 11481
摘要:求 1∼n 的排列 A 中,满足前 m 个数中,刚好有 K 个数使得 A[ i ]=i 的 AA 的个数。 错位排列 #include<bits/stdc++.h> using namespace std; const int mod=1e9+7; #define int long long int 阅读全文
posted @ 2023-04-20 02:06 towboat 阅读(15) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示