![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
cqggcqggcqggcqgg
这个作者很懒,什么都没留下…
展开
-
【算法设计与程序分析】0-1背包问题 (DP + 跳跃点 + 空间优化)
#include<iostream>#include<queue>#include<algorithm>#define MAXNUM 30using namespace std;class Bag{ //在跳跃点解法时使用 public: Bag(){ val = 0; weight = 0; } public: int val; int weight; friend bool operator < (Bag a,Bag转载 2020-12-07 19:42:55 · 695 阅读 · 0 评论 -
蚁群算法求解TSP旅行商问题
问题:蚁群算法求解TSP旅行商问题问题描述(数据来源):http://www.docin.com/p-513276781.html数据 china.txt:116.46 39.92117.2 39.13121.48 31.22106.54 29.5991.11 29.9787.68 43.77106.27 38.47111.65 40.82108.33 22.84126.63 45.75125.35 43.88123.38 41.8114.48 38.03112.53 37.原创 2020-11-19 22:19:58 · 449 阅读 · 0 评论 -
遗传算法求解区间[0, 31]上的二次函数f(x) = x ^ 2的最大值
问题:遗传算法求解区间[0, 31]上的二次函数f(x) = x ^ 2的最大值#include <bits/stdc++.h>using namespace std;const int maxn = 10; //种群数量 const int bit = 5; const int iteration = 200; //迭代次数 const double pc = 0.4; //交叉概率 const double pm = 0.02; //变异概率原创 2020-11-19 21:52:50 · 5125 阅读 · 0 评论 -
【数据结构】迪杰斯特拉(dijkstra)算法 单源最短路径(源点到其它点的最短距离)
#include <iostream>#include <cstring>#define maxn 500#define INF 0x3f3f3f3fusing namespace std;int graph[maxn][maxn]; //尽量定义全局变量int vis[maxn]; //存已查找的顶点int dis[maxn]; //各顶点到源点距离int n, m; //顶点数、边数void dijkstra(int原创 2020-10-06 17:19:46 · 846 阅读 · 0 评论