算法设计与分析
hxj0x
只有学习才能学会学习。
展开
-
动态规划——最长公共子序列
#include<stdio.h>#include<string.h>#define max(a, b) a > b ? a : b#define N 1010char x[N], y[N];int dp[N][N];int main(){ scanf("%s%s", x+1, y+1); int lx = strlen(x+1), ly = strlen(y+1); int i, j; for(i = 1; i <=原创 2021-05-09 23:42:45 · 75 阅读 · 0 评论 -
贪心——活动安排
#include <iostream>#include <algorithm>#include <cstdio>using namespace std;const int N = 1010;int T, n;class act{public: int s; int f;};bool cmp(act x1, act x2){ return x1.f < x2.f;}int main(){ // Ca原创 2021-05-08 22:51:34 · 86 阅读 · 0 评论 -
动态规划——矩阵连乘
#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;const int N = 650;int T, n;int m[N][2];int dp[N][N];// dp[i][j] 表示矩阵m[j] ~ m[j]的最小乘法次数int main(){ cin >> T; whil原创 2021-05-05 18:15:09 · 59 阅读 · 0 评论 -
三种快速排序
/** * 3种快排的实现方式,1是不适合重复元素多,2可以适应重复元素多(建议使用),3可以优化重复元素多的时间 */public class Code_07_QuickSort { public static void quickSort(int[] arr) { if (arr == null || arr.length < 2) { return; } int L = 0, R = arr.length - 1; quickSort(arr, L, R); }原创 2020-10-30 12:23:24 · 156 阅读 · 0 评论 -
分治——棋盘覆盖
棋盘覆盖视频讲解东北大学慕课[video(video-BWWlnR2Z-1604030474317)(type-bilibili)(url-https://player.bilibili.com/player.html?aid=100009146)(image-https://ss.csdn.net/p?http://i1.hdslb.com/bfs/archive/0f5367f1930cc6d4528cc364c2f7afb02a45c13d.jpg)(东北大学慕课)]问题描述在一个2k×2k.原创 2020-10-30 12:02:53 · 205 阅读 · 0 评论