08 2021 档案
摘要:这道题记录状态的思想挺好的 假如棋子在(i,j): 那么它上面空格的编号为((i-1)*4+(j-1)*4+0) 那么它下面空格的编号为((i-1)*4+(j-1)*4+1) 那么它左面空格的编号为((i-1)*4+(j-1)*4+2) 那么它右面空格的编号为((i-1)*4+(j-1)*4+3)
阅读全文
摘要:(1)杨辉三角 #include<iostream> #include<cstdio> #include<cmath> #include<map> #include<queue> #include<algorithm> #include<cstring> #include<string> using
阅读全文
摘要:高精加 string jia(string a,string b){ string jg=""; int i,j,k,c=0; int a1[1001]={0},b1[1001]={0},c1[1001]={0}; for(i=1;i<=a.size();i++) a1[i]=a[a.size()-
阅读全文
摘要:传送门 LCA 但桶用的很妙 真的很妙b( ̄▽ ̄)d #include<iostream> #include<cstdio> using namespace std; int Size1=500000,dist[1000001],h1[1000001],h2[1000001],b1[1000001]
阅读全文
摘要:传送门 感想:奇奇怪怪的STL和奇奇怪怪的折半 #include<iostream> #include<cstdio> #include<cmath> #include<map> #include<queue> #include<algorithm> #include<cstring> #inclu
阅读全文
摘要:将一个数 a 拆成若干数相加,使得这若干个数的 LCM 最大。 a ≤ 30000 首先,拆成质数是最优的 我实在没想到这题居然是DP 如果知道这题是用DP就好办了 传送门
阅读全文
摘要:注:π(x):1~x的素数个数 当x足够大,趋近于x/ln(x)
阅读全文
摘要:题目传送门 题目大意就是给定一棵 n 个点的树,m 次询问,每次询问给出三个点,问应该选 择哪个点,使得三点到该点的距离和最小。 容易发现,集合点一定在两两点的路径上,三者 LCA 中的一个。 其最短路径即为俩俩点距离和的一半 时间复杂度为 O(m log n) 没打代码,嘿嘿
阅读全文
摘要:例题 网上查多叉转二叉好处就是好实现(好打代码)?! #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int dp[1001][1001],c[1001][1001]
阅读全文
摘要:T4 逆向,考虑增加一条边,将两个连通块合并了 考虑新连通块的直径与原来两个连通块直径的关系 设新连通块的直径端点为 x, y,原两个连通块的直径端点为a, b, c, d。 容易发现,x, y 一定是 a, b, c, d 其中之一。 除去原先两个连通块直径长度,乘上新连通块直径长度(除法需乘法逆
阅读全文
摘要:当n∈【30,40】可以考虑下 复杂度大概是O(2^(n/2)) 算半个模板题吧 某位机房大佬(折半+STL) #include<bits/stdc++.h> using namespace std; long long n,m,w[101],mid,a[1<<20],b[1<<20],sum1,s
阅读全文
摘要:原题在此 某位大佬用线段树做的 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int N=3e5+7; inline int read(){ i
阅读全文
摘要:#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int sum,tree[300005],ll[300005],rank[300005],n; struct Node{ int num,val;
阅读全文
摘要:传送门 某位师兄出的题 也可当01trie模板用 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<map> #include<algorithm> #include<queue> #defi
阅读全文
摘要:#include<iostream> #include<cstdio> using namespace std; int a[100001]={0}; int dg_sort(int l,int r){ int mid=a[(l+r)/2]; int i=l,j=r; while(i<=j){ wh
阅读全文
摘要:AT4298 [ABC118D] Match Matching #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<map> #include<algorithm> #include<queue
阅读全文
摘要:传送门 插入 xx 数 删除 xx 数(若有多个相同的数,因只删除一个) 查询 xx 数的排名(排名定义为比当前数小的数的个数 +1+1 ) 查询排名为 xx 的数 求 xx 的前驱(前驱定义为小于 xx,且最大的数) 求 xx 的后继(后继定义为大于 xx,且最小的数) #include<iost
阅读全文
摘要:题目传送门1 较好的博客传送门 #include<iostream> #include<vector> #include<cstdio> #include<algorithm> #include<map> #define INF 0x7f7f7f using namespace std; int n
阅读全文

浙公网安备 33010602011771号