LH_Coffee
LH_Coffee
全部文章
分类
归档
标签
去牛客网
登录
/
注册
LH_Coffee的博客
全部文章
(共22篇)
题解 | 村村通工程
#include<bits/stdc++.h> using namespace std; const int N=1e5+5; int f[N]; int find(int x){ if(f[x]!=x)f[x]=find(f[x]); return f[x]; } s...
2026-04-25
0
6
题解 | 修复公路
#include<bits/stdc++.h> using namespace std; const int N=1e3+5; const int M=1e5+5; int f[N]; struct node{ int x,y,w; }a[M]; int find(int x...
2026-04-25
0
8
题解 | kmp算法
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算模板串S在文本串T中出现了多少次 * @param S string字符串 模板串 * @pa...
2026-04-22
1
15
题解 | 单调栈
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型vector * @return int整型vector...
2026-04-19
1
17
题解 | 迷宫问题
#include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; const int N=105; int mp[N][N]; PII path[N][N]; queue<PII>q; i...
2026-03-09
1
43
题解 | 小红的双排列删除得分
#include <bits/stdc++.h> using namespace std; struct nod { int fir; // 数字第一次出现的位置 int sec; // 数字第二次出现的位置 // 带默认参数的构造函数 nod(in...
2026-02-28
2
68
题解 | 跳台阶
动态规划三部曲(递推---->递推+记忆化搜索----->自底到顶的动态规划---->状态压缩)1.递推(自顶到底)本题可类比斐波那契,每次跳台阶与前一个和前两个有关所以到n目标位置有如下关系:f(n)=f(n-1)+f(n-2) f是计算方案数的函数,这是递推的核心,再加上边界讨...
2026-02-04
4
95
题解 | 【模板】快速幂
#include <iostream> using namespace std; using ll=long long; ll f(ll a,ll b,ll p){ ll ans=1; a%=p; while(b){ if(b&1){ ...
2026-02-02
1
82
题解 | 斐波那契数列
#include <iostream> using namespace std; using ll=long long; ll fbnq(int n){ if(n<=2)return 1; return fbnq(n-1)+fbnq(n-2); } int main...
2026-02-02
1
88
题解 | 小红的数字分裂
#include <bits/stdc++.h> using namespace std; using ll= long long; int main() { ll n; cin>>n; vector<int>v(n,0); for...
2026-02-02
1
81
首页
上一页
1
2
3
下一页
末页