算法
tutoutoututututu
这个作者很懒,什么都没留下…
展开
-
P1102 A-B 数对 二分解法
加深理解STL中的upper_bound和lower_bound函数:原创 2022-09-03 10:44:40 · 96 阅读 · 0 评论 -
二叉树:已知两种序列,求另外一种序列
已知二叉树的两种序列,求另外一种序列原创 2022-08-29 12:09:01 · 326 阅读 · 0 评论 -
线性动态规划
P1514 引水入城记忆顶层的最长覆盖区间若底层存在未访问的城市,输出0;若底层城市都能访问到,根据顶层的最长覆盖区间贪心选择最少的顶层城市#include <bits/stdc++.h>using namespace std;const int maxn = 5e2 + 10;int n, m;int x[4] = {-1, 1, 0, 0}, y[4] = {0, 0, 1, -1};// 最长覆盖区间,分别用两个数组存储左端点以及右端点int h[maxn][maxn原创 2022-02-12 22:55:32 · 56 阅读 · 0 评论 -
搜索之记忆化搜索
本篇为三个例题P1514 引水入城记忆顶层的最长覆盖区间若底层存在未访问的城市,输出0;若底层城市都能访问到,根据顶层的最长覆盖区间贪心选择最少的顶层城市#include <bits/stdc++.h>using namespace std;const int maxn = 5e2 + 10;int n, m;int x[4] = {-1, 1, 0, 0}, y[4] = {0, 0, 1, -1};// 最长覆盖区间,分别用两个数组存储左端点以及右端点int h[.原创 2022-02-09 12:51:04 · 424 阅读 · 0 评论 -
搜索之广搜
P1162 填涂颜色在方阵外围加一圈零,方便搜索bfs代码:#include<bits/stdc++.h>using namespace std;int mapp[32][32] = {0}, n;bool visit[32][32] = {0};int dis_x[4] = {0, 0, 1, -1};int dis_y[4] = {1, -1, 0, 0};struct Node{ int x; int y;}; void bfs() { queue&原创 2022-02-03 18:34:26 · 461 阅读 · 0 评论 -
搜索之深搜dfs
P1219 八皇后#include <bits/stdc++.h>using namespace std; int n, ans[14], num = 0;void dfs(int f) { //f为当前层 if(f == n + 1) { num++; if(num <= 3){ for(int i = 1; i <= n; i++) { cout << ans[i] << ' '; } cout <原创 2022-01-30 22:41:50 · 745 阅读 · 0 评论 -
分治法例题
题目来源:洛谷P1226 【模板】快速幂||取余运算a为temp, n为几次幂取余运算的性质(A+B)%b=(A%b+B%b)%b(A×B)% b = ((A%b)×(B%b))%busing namespace std;typedef long long ll;ll quickPower(int a, int b, int c) { ll ans = 1, temp = a; while(b) { if(b & 1) { ans *= temp; ans %=原创 2022-01-19 21:22:07 · 518 阅读 · 0 评论