随笔分类 -  某些模板

摘要:题链 #include <bits/stdc++.h> using namespace std; #define LL long long #define ls rt<<1 #define rs rt<<1|1 #define eps 1e-9 #define mod 998244353 #defi 阅读全文
posted @ 2021-08-01 22:03 棉被sunlie 阅读(124) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; inline __int128 read() { __int128 x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') f=-1; 阅读全文
posted @ 2021-06-05 18:33 棉被sunlie 阅读(151) 评论(0) 推荐(0)
摘要:LL qpow(LL x,LL y){ LL ans = 1; for(;y;y>>=1){ if(y&1) ans = (ans*x)%mod; x = (x*x)%mod; } return ans%mod; } LL inv(LL x,LL y){ // x/y; return ( (x%mo 阅读全文
posted @ 2021-05-11 13:38 棉被sunlie 阅读(51) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; #define LL long long const int MAXN = 5009; int N; struct Point { double x, y; }p[MAXN], C; // p[i] 表示点集 阅读全文
posted @ 2021-03-09 16:58 棉被sunlie 阅读(60) 评论(0) 推荐(0)
摘要:习自 #include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <stdio.h> #include <string.h> #include <stdlib.h> using namespace std; # 阅读全文
posted @ 2021-03-09 16:51 棉被sunlie 阅读(119) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS 9 #define mod 9901 using namesp 阅读全文
posted @ 2020-07-24 22:44 棉被sunlie 阅读(162) 评论(0) 推荐(0)
摘要:该算法学习来自 b站 示例代码 1 输出的访问顺序与输入相反 #include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS 阅读全文
posted @ 2020-07-14 20:07 棉被sunlie 阅读(96) 评论(0) 推荐(0)
摘要:来源 简单易懂的详解 . 我愿称之为 ntr 算法 核心代码 LL mp[MS][MS]; // 关系图 1 有 0 无 LL vis[MS]; // 表示是否询问过 LL match[MS]; // 表示匹配关系 int find(LL x){ for(int i=1;i<=m;i++){ if( 阅读全文
posted @ 2020-07-14 16:56 棉被sunlie 阅读(125) 评论(0) 推荐(0)
摘要:单模式串匹配 KMP算法 推理过程见详解 . #include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS 100009 # 阅读全文
posted @ 2020-06-22 22:51 棉被sunlie 阅读(162) 评论(0) 推荐(0)
摘要:并查集代码真是又短又有趣,易于理解见详解 . int n,m,k; int p[MS],tr[MS],fa[MS]; void init(){ for(int i=1;i<=n;i++) fa[i] = i; } int find(int x){ if(x == fa[x]) return x; e 阅读全文
posted @ 2020-06-19 21:14 棉被sunlie 阅读(101) 评论(0) 推荐(0)
摘要:单点更新 区间查询 直接利用树状数组存储原数组 #include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS 100009 阅读全文
posted @ 2020-06-19 20:49 棉被sunlie 阅读(111) 评论(0) 推荐(0)
摘要:递归 #include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS 100009 #define mss 17 using 阅读全文
posted @ 2020-06-17 19:06 棉被sunlie 阅读(109) 评论(0) 推荐(0)
摘要:直接求解 LL factor(LL x){ LL cnt = 0; for(int i=1;i<=sqrt(x);i++){ if(x%i==0){ if(x/i == i) cnt += i; // ex: 9 = 3 * 3 else cnt += i + x/i; } } return cnt 阅读全文
posted @ 2020-06-13 20:32 棉被sunlie 阅读(416) 评论(0) 推荐(0)
摘要:判断素数 int is_prime(int n) { if(n==1)return 0; for(int i=2;i*i<=n;i++){ if(n%i==0) return 0; } return 1; } 普通筛 int p[MS]; memset(p,0,sizeof p); for(int 阅读全文
posted @ 2020-06-11 16:19 棉被sunlie 阅读(23) 评论(0) 推荐(0)
摘要:公式 代码模拟公式计算 例:C(7,3)则循环三次每次分别为 5 / 1 , 5 * 6 / 1 * 2 , 5 * 6 * 7 / 1 * 2 * 3 C(n,m) #define LL long long LL C(LL n,LL m) // n为下标 m为上标 { LL k,sum = 1; 阅读全文
posted @ 2020-06-11 15:47 棉被sunlie 阅读(141) 评论(0) 推荐(0)
摘要:inline LL read(){ LL x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();} while (isdigit(ch)){x=x*10+ch-48;ch=getchar();} 阅读全文
posted @ 2020-06-11 15:37 棉被sunlie 阅读(77) 评论(0) 推荐(0)
摘要:#define LL long long LL qmul(LL a,LL b,LL mod){ LL ans = 0; for(;b;b>>=1){ if(b&1) ans = (ans+a)%mod; a = a*2%mod; } return ans; } 阅读全文
posted @ 2020-06-11 15:34 棉被sunlie 阅读(62) 评论(0) 推荐(0)
摘要:循环 #define LL long long LL qpow(LL n,LL m){ LL ans = 1%mod; while(m>0){ if(m&1) ans = ans*n%mod; n = n*n%mod; m >>= 1; } return ans; } 递归 #define LL l 阅读全文
posted @ 2020-06-11 15:05 棉被sunlie 阅读(19) 评论(0) 推荐(0)