随笔分类 -  御用模板

摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=10005; ll n,m,sum,tim,top,s; ll p[maxn],head[maxn],sd[maxn],dfn[maxn 阅读全文
posted @ 2021-05-28 21:29 _LH2000 阅读(49) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; namespace MCMF { const int MAXN = 10000, MAXM = 10000, INF = 0x7fffffff; int head[M 阅读全文
posted @ 2021-05-24 19:26 _LH2000 阅读(58) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; int G[1003][1003]; int match[1003]; int rb[1004]; int k,mg,nb; ll n; bool dfs(int x 阅读全文
posted @ 2021-05-24 09:11 _LH2000 阅读(37) 评论(0) 推荐(0)
摘要:// luogu-judger-enable-o2 #include<cstring> #include<cstdio> #include<queue> #define min(a,b) a<b?a:b #define N 10001 #define M 100001 using namespace 阅读全文
posted @ 2021-04-29 20:10 _LH2000 阅读(33) 评论(0) 推荐(0)
摘要:mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); double rnd(double l, double r){return uniform_real_distribution<double>(l,r)(rng) 阅读全文
posted @ 2021-04-22 15:59 _LH2000 阅读(83) 评论(0) 推荐(0)
摘要://本模板是离散后对权值建树 #include<bits/stdc++.h> #define mid (l+r>>1) using namespace std; const int N=2e5+10; struct TR { int sum,lo,ro; }tr[N<<5]; int tr_cnt; 阅读全文
posted @ 2021-04-14 20:40 _LH2000 阅读(51) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 10; struct CMT { int seq[N << 1], rt[N], tot, m; struct { int l, r; long long sum; } 阅读全文
posted @ 2021-04-13 21:42 _LH2000 阅读(69) 评论(0) 推荐(0)
摘要:double l = 0,r = 10000; while(r-l>=0.01){//精度问题 double m1 = l + (r-l)/3.0,m2 = r - (r-l)/3.0; if(f(m1)<f(m2)) l = m1; else r = m2; } 阅读全文
posted @ 2021-04-08 11:30 _LH2000 阅读(63) 评论(0) 推荐(0)
摘要://小G定义了两个函数F(n)为n的约数和,G(n)为F(1)+F(2)+...+F(n-1)+F(n) ll G(ll x){ ll res=0; for(ll i=1;i<=x;) { ll r = x/(x/i); res += (x/i) * (r + i) * (r - i + 1) / 阅读全文
posted @ 2021-03-08 22:15 _LH2000 阅读(98) 评论(0) 推荐(0)
摘要:#include<iostream> #include<iomanip> #include<cstdio> #include<vector> #include<cmath> #include<string> #include<cstring> #include<algorithm> #include 阅读全文
posted @ 2021-02-20 19:06 _LH2000 阅读(76) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> #define fi first #define se second #define lo (o<<1) #define ro (o<<1|1) #define mid (l+r>>1) using namespace std; typedef lon 阅读全文
posted @ 2021-02-20 15:31 _LH2000 阅读(82) 评论(0) 推荐(0)
摘要:#include <functional> template <typename T> inline void hash_combine(std::size_t &seed, const T &val) { seed ^= std::hash<T>()(val) + 0x9e3779b9 + (se 阅读全文
posted @ 2021-02-16 17:28 _LH2000 阅读(58) 评论(0) 推荐(0)
摘要:第一步 : 给出方程 ax + by = c 。 第二步 : 算出 辗转相除法 gcd(a, b) 。 第三步 : 运用 扩展欧几里德 ex_gcd(a, b)-》 ax + by = gcd(a,b) 的 一组解(x, y) 。 第三步: 根据 c % gcd(a, b) 判断是否 ax + by 阅读全文
posted @ 2021-02-04 11:44 _LH2000 阅读(531) 评论(0) 推荐(0)
摘要:int prime[1100000],primesize; bool isprime[11000000]; void getlist(int listsize){ memset(isprime,1,sizeof(isprime)); isprime[1]=false; for(int i=2;i<= 阅读全文
posted @ 2021-01-13 21:07 _LH2000 阅读(58) 评论(0) 推荐(0)
摘要:https://codeforces.ml/contest/1364/problem/D /* 给出一张 n 个点的无向连通图和一个常数 k。 你需要解决以下两个问题的任何一个: 1. 找出一个大小为 k/2 (向上取整)的独立集。 2. 找出一个大小不超过 k 的环。 独立集是一个点的集合,满足其 阅读全文
posted @ 2021-01-13 17:06 _LH2000 阅读(110) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define rush! ios::sync_with_stdio(false);cin.tie(0); c 阅读全文
posted @ 2021-01-12 15:57 _LH2000 阅读(147) 评论(0) 推荐(0)
摘要:int lowbit(int x){ return x & -x; } 上面的代码可以统计x 的二进制中1 的数量; lowbit(x ^ y) 上面的代码则可以统计x和y中不同位的数量 阅读全文
posted @ 2021-01-10 18:38 _LH2000 阅读(92) 评论(0) 推荐(0)
摘要:C++的 bitset 在 bitset 头文件中,它是一种类似数组的结构,它的每一个元素只能是0或1,每个元素仅用1bit空间。 下面是具体用法 bitset<4> bitset1; //无参构造,长度为4,默认每一位为0 bitset<8> bitset2(12); //长度为8,二进制保存,前 阅读全文
posted @ 2021-01-10 13:44 _LH2000 阅读(119) 评论(0) 推荐(0)
摘要:int exgcd(int a,int b,int&x,int&y) { if(b==0){ x=1,y=0; return a; } int r=exgcd(b,a%b,y,x); y-=a/b*x; return r; } 阅读全文
posted @ 2021-01-01 21:45 _LH2000 阅读(75) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> #define N 1500 #define inf 999999999 using namespace std; int a[N],bs[N],nx=0,ny=0,k; int linky[N],lx[N],ly[N],slack[N]; int 阅读全文
posted @ 2020-12-17 22:05 _LH2000 阅读(123) 评论(0) 推荐(0)