当前位置: 首页 > news >正文

货物公司网站建设方案免费seo在线优化

货物公司网站建设方案,免费seo在线优化,网络外包公司,2023年8月疫情还会严重吗文章目录进制转换高精度加/乘法搜索BFSDFS树二叉树遍历图Dijkstra算法Kruskal算法动态规划最长公共子序列(LCS)最长上升子序列(LIS)KMP算法进制转换 #include <iostream> #include <string> #include <cmath> #include <iomanip> #include <algori…

文章目录

  • 进制转换
  • 高精度加/乘法
  • 搜索
    • BFS
    • DFS
    • 二叉树遍历
    • Dijkstra算法
    • Kruskal算法
  • 动态规划
    • 最长公共子序列(LCS)
    • 最长上升子序列(LIS)
    • KMP算法

进制转换

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>using namespace std;
string a="0123456789ABCDEF";
void d_to(int x,int m){if (x==0)return;d_to(x/m,m);cout<<a[x%m];}int main() {int x,m;cin>>x>>m;d_to(x,m);return 0;}

高精度加/乘法

#include <bits/stdc++.h>using namespace std;
int a[80], g[80], c[80];string add(string x, string y) {string temp;for (int i = 0; i < x.size(); ++i) {a[x.size() - i - 1] = x[i] - '0';}for (int i = 0; i < y.size(); ++i) {g[y.size() - i - 1] = y[i] - '0';}int ans = max(x.size(), y.size());for (int i = 0; i < ans; ++i) {c[i] += a[i] + g[i];c[i + 1] = c[i] / 10;c[i] %= 10;}ans++;if (c[ans - 1] == 0 && ans > 1)ans--;for (int i = 0; i < ans; ++i) {temp += to_string(c[ans - i - 1]);}memset(a, 0, sizeof(a));memset(g, 0, sizeof(g));memset(c, 0, sizeof(c));return temp;
}string mul(string x, string y) {string temp;for (int i = 0; i < x.size(); ++i) {a[x.size() - i - 1] = x[i] - '0';}for (int i = 0; i < y.size(); ++i) {g[y.size() - i - 1] = y[i] - '0';}int ans = max(x.size(), y.size());for (int i = 0; i < ans; ++i) {for (int j = 0; j < ans; ++j) {c[i + j] += a[i] * g[j];c[i + j + 1] += c[i + j] / 10;c[i + j] %= 10;}}int as = x.size() + y.size();while (c[as - 1] == 0 && as > 1)as--;for (int i = 0; i < as; ++i) {temp += to_string(c[as - i - 1]);}memset(a, 0, sizeof(a));memset(g, 0, sizeof(g));memset(c, 0, sizeof(c));return temp;
}int main() {int n;string s = "0";cin >> n;for (int i = 1; i <= n; ++i) {string jc = "1";for (int j = 1; j <= i; ++j) {string k = to_string(j);jc = mul(jc, k);}s = add(s, jc);}cout << s;
}

搜索

BFS

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>using namespace std;
int a[100][100], v[100][100];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct point {int x;int y;int step;
};
queue<point> r;int main() {int n, m, startx, starty, p, q;cin >> n >> m;for (int i = 1; i <= n; ++i) {for (int j = 1; j <= m; ++j) {cin >> a[i][j];}}cin >> startx >> starty >> p >> q;// BFSpoint start;start.x = startx;start.y = starty;start.step = 0;r.push(start);v[startx][starty] = 1;int flag = 0;while (!r.empty()) {int x = r.front().x;int y = r.front().y;if (x == p && y == q) {flag = 1;cout << r.front().step;break;}for (int i = 0; i < 4; ++i) {int tx, ty;tx = x + dx[i];ty = y + dy[i];if (a[tx][ty] == 1 && v[tx][ty] == 0) {point temp;temp.x = tx;temp.y = ty;temp.step = r.front().step + 1;r.push(temp);v[tx][ty] = 1;}}r.pop();}if (flag==0){cout<<"No Answer";}return 0;}

DFS

#include <iostream>using namespace std;
int p, q;
int miN = 99999999;
int a[100][100];// 1是空地,2是障碍物
int v[100][100];//0表示未访问,1表示访问
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};void dfs(int x, int y, int step) {if (x == p && y == q) {if (step < miN)miN = step;return;}// 顺时针试探for (int i = 0; i < 4; ++i) {int tx, ty;tx = x + dx[i];ty = y + dy[i];if (a[tx][ty] == 1 && v[tx][ty] == 0) {v[tx][ty] = 1;dfs(tx, ty, step + 1);v[tx][ty] = 0;}}return;
}int main() {int m, n;int startx, starty;cin >> m >> n;for (int i = 1; i <= m; ++i) {for (int j = 1; j <= n; ++j) {cin >> a[i][j];}}cin >> startx >> starty >> p >> q;v[startx][starty] = 1;dfs(startx, starty, 0);cout << miN;return 0;}

二叉树遍历

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>using namespace std;
typedef struct node {char data;struct node *lchild, *rchild;
} *BitTree;void CreateBitTree(BitTree &T) {char c;cin >> c;if (c == '0')T = NULL;else {T = new node;T->data = c;CreateBitTree(T->lchild);CreateBitTree(T->rchild);}
}void PreOrder(BitTree T) {if (T != NULL) {cout << T->data << ' ';PreOrder(T->lchild);PreOrder(T->rchild);}
}void InOrder(BitTree T) {if (T != NULL) {InOrder(T->lchild);cout << T->data << ' ';InOrder(T->rchild);}
}void PostOrder(BitTree T) {if (T != NULL) {PostOrder(T->lchild);PostOrder(T->rchild);cout << T->data << ' ';}
}int main() {BitTree T;CreateBitTree(T);cout << "前序遍历:";PreOrder(T);cout << endl;cout << "中序遍历:";InOrder(T);cout << endl;cout << "后序遍历:";PostOrder(T);
}

Dijkstra算法

#include <iostream>
#include <algorithm>
#include <string>
#include <queue>#define inf 0x3f3f3f3f
using namespace std;
const int M = 1e4 + 10;
const int N = 1000 + 10;
int n, m, s;
int mp[N][N];
int dis[N], vis[N];
int pre[N];void init() {memset(mp, inf, sizeof(mp));
}void dijkstra(int s) {memset(dis, 0x3f, sizeof(dis));memset(vis, 0, sizeof(vis));dis[s] = 0;while (1) {int mini = 0, miN = inf;for (int i = 1; i <= n; ++i) {if (vis[i] == 0 && miN > dis[i]) {mini = i;miN = dis[i];}}if (mini == 0)break;vis[mini] = 1;for (int i = 1; i <= n; ++i) {if (vis[i] == 0 && dis[i] > dis[mini] + mp[mini][i]) {dis[i] = dis[mini] + mp[mini][i];pre[i]=mini;}}}
}void output(int z){if (z==0)return;output(pre[z]);cout<<z<<"->";
}int main() {init();cin >> n >> m >> s;for (int i = 0; i < m; ++i) {int u, v, w;cin >> u >> v >> w;if (w < mp[u][v]) {mp[u][v] = mp[v][u] = w;}}dijkstra(s);cout<<dis[n]<<endl;for (int i = 1; i <= n; ++i) {output(i);cout<<endl;}
}

Kruskal算法

#include <iostream>using namespace std;const int maxn = 5005;struct node {int u, v, w;
} edge[200001];int cmp(node x, node y) {return x.w < y.w;
}int fa[maxn];int find(int x) {if (x == fa[x])return x;fa[x] = find(fa[x]);return fa[x];
}int main() {int N, M;cin >> N >> M; // N是结点,M是边for (int i = 0; i < M; ++i) {cin >> edge[i].u >> edge[i].v >> edge[i].w;}for (int i = 1; i <= N; ++i) {fa[i] = i;}int sum = 0;int total = 0;sort(edge, edge + M, cmp);for (int i = 0; i < M; ++i) {int fx = find(edge[i].u);int fy = find(edge[i].v);if (fx != fy) {fa[fx] = fy;sum += edge[i].w;total++;}}if (total < N - 1)cout << "orz";elsecout << sum;return 0;
}

动态规划

最长公共子序列(LCS)

#include <iostream>
#include <string>using namespace std;
const int MAX = 1000 + 10;
string s1, s2;
int f[MAX][MAX] = {0};
string ans;void LCS(int i, int j) {if (i == 0 || j == 0)return;if (s1[i - 1] == s2[j - 1]) {LCS(i - 1, j - 1);cout << s1[i - 1];} else if (f[i - 1][j] > f[i][j - 1]) {LCS(i - 1, j);} else {LCS(i, j - 1);}}int main() {cin >> s1 >> s2;int n = s1.size();int m = s2.size();for (int i = 1; i <= n; ++i) {for (int j = 1; j <= m; ++j) {if (s1[i - 1] == s2[j - 1]) {f[i][j] = 1 + f[i - 1][j - 1];} else {f[i][j] = max(f[i - 1][j], f[i][j - 1]);}}}cout << f[n][m] << endl;LCS(n, m);return 0;
}

最长上升子序列(LIS)

#include <iostream>using namespace std;
const int MAX = 1000 + 10;
int a[MAX];
int dp[MAX];
int n;int LIS() {int ans = 0;for (int i = 1; i <= n; ++i) {dp[i] = 1;for (int j = 1; j < i; ++j) {if (a[j] < a[i]) {dp[i] = max(dp[i], dp[j] + 1);}}ans = max(ans, dp[i]);}return ans;
}int main() {cin >> n;for (int i = 1; i <= n; ++i) {cin >> a[i];}int res = LIS();cout << res;return 0;
}

KMP算法

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>using namespace std;
int Next[1000005];void getNext(char s[], int len) {int j = -1;Next[0] = -1;for (int i = 1; i < len; ++i) {while (j != -1 && s[i] != s[j + 1]) {j = Next[j];}if (s[i] == s[j + 1]) {j++;}Next[i] = j;}
}int KMP(char text[], char patten[]) {int n = strlen(text), m = strlen(patten);getNext(patten, m);int j = -1, ans = 0;for (int i = 0; i < n; ++i) {while (j != -1 && text[i] != patten[j + 1]) {j = Next[j];}if (text[i] == patten[j + 1]) {j++;}if (j == m - 1) {ans++;j = Next[j];}}return ans;
}int main() {char s1[1000005], s2[1000005];cin >> s1 >> s2;int a=KMP(s1, s2);cout<<a;
}

文章转载自:
http://busywork.sfwd.cn
http://immuration.sfwd.cn
http://unfilmed.sfwd.cn
http://thinnish.sfwd.cn
http://vividly.sfwd.cn
http://grueling.sfwd.cn
http://jaggy.sfwd.cn
http://magazine.sfwd.cn
http://damnify.sfwd.cn
http://quinquevalent.sfwd.cn
http://chromogen.sfwd.cn
http://subchloride.sfwd.cn
http://toxaphene.sfwd.cn
http://anglophone.sfwd.cn
http://crackable.sfwd.cn
http://headrace.sfwd.cn
http://romanza.sfwd.cn
http://ccsa.sfwd.cn
http://shivery.sfwd.cn
http://poorly.sfwd.cn
http://degression.sfwd.cn
http://rafter.sfwd.cn
http://fluoridization.sfwd.cn
http://obstinate.sfwd.cn
http://boise.sfwd.cn
http://indiscreetly.sfwd.cn
http://jiangxi.sfwd.cn
http://nailer.sfwd.cn
http://sideburns.sfwd.cn
http://despicable.sfwd.cn
http://savey.sfwd.cn
http://stolid.sfwd.cn
http://gratulatory.sfwd.cn
http://necessitude.sfwd.cn
http://constellate.sfwd.cn
http://magnificence.sfwd.cn
http://forum.sfwd.cn
http://croesus.sfwd.cn
http://hugely.sfwd.cn
http://hexagram.sfwd.cn
http://weet.sfwd.cn
http://alguazil.sfwd.cn
http://dearborn.sfwd.cn
http://canonically.sfwd.cn
http://bodoni.sfwd.cn
http://capnomancy.sfwd.cn
http://negotiable.sfwd.cn
http://postmultiply.sfwd.cn
http://euphorbia.sfwd.cn
http://tarsectomy.sfwd.cn
http://outstride.sfwd.cn
http://sheriffwick.sfwd.cn
http://maris.sfwd.cn
http://centurion.sfwd.cn
http://legitimacy.sfwd.cn
http://mininuke.sfwd.cn
http://enginery.sfwd.cn
http://godthaab.sfwd.cn
http://regicide.sfwd.cn
http://barnaby.sfwd.cn
http://pearson.sfwd.cn
http://pododynia.sfwd.cn
http://intraswitch.sfwd.cn
http://sheraton.sfwd.cn
http://molar.sfwd.cn
http://puce.sfwd.cn
http://radioactive.sfwd.cn
http://aspirated.sfwd.cn
http://disaggregate.sfwd.cn
http://neutralism.sfwd.cn
http://rubydazzler.sfwd.cn
http://maze.sfwd.cn
http://nonmiscibility.sfwd.cn
http://socle.sfwd.cn
http://virilize.sfwd.cn
http://razorbill.sfwd.cn
http://fosse.sfwd.cn
http://tribunary.sfwd.cn
http://cheeringly.sfwd.cn
http://arboriculture.sfwd.cn
http://disinhume.sfwd.cn
http://people.sfwd.cn
http://swaybacked.sfwd.cn
http://kitchener.sfwd.cn
http://kobold.sfwd.cn
http://karma.sfwd.cn
http://buna.sfwd.cn
http://protophloem.sfwd.cn
http://ziarat.sfwd.cn
http://hydrodesulfurization.sfwd.cn
http://noachian.sfwd.cn
http://anticipation.sfwd.cn
http://adornment.sfwd.cn
http://peperoni.sfwd.cn
http://unifactorial.sfwd.cn
http://zhejiang.sfwd.cn
http://inturned.sfwd.cn
http://trunnel.sfwd.cn
http://dodecastyle.sfwd.cn
http://phototransistor.sfwd.cn
http://www.hrbkazy.com/news/92443.html

相关文章:

  • 网站后台管理系统怎么做的网站查询域名ip
  • 儋州市住房和城乡建设局官方网站优化推广什么意思
  • 写微信公众号用什么软件seo是什么味
  • 科技官网广州谷歌seo
  • 网站目录权限设置 user模板建站的网站
  • 有人用我的企业做网站权重查询
  • 打码网站怎么做接口怎么做宣传推广
  • 邢台网seo关键词排优化软件
  • 做的好的日本网站设计百度实名认证
  • java语言做网站全网营销推广平台有哪些
  • 老司机做爰网站网站运营培训学校
  • 直销软件网站开发qq推广引流网站
  • wordpress2345官网排名优化
  • 衡水做网站网站公司网站建设
  • 网站推广策略每日关键词搜索排行
  • php网站建设工程师郑州网站建设方案优化
  • 聊城手机站网站公司软文发布
  • 手机做公司网站资阳地seo
  • wordpress 新建分类页面seo推广服务
  • 网站建设与管理大学生职业规划济南百度快照推广公司
  • 杭州网站建设seo优化企业推广文案
  • 网站开发json解析专业seo推广
  • 小程序定制公司设计方案seo网站推广实例
  • 做微博网站好不好公司官网制作多少钱
  • 怎么做网站站内搜索全网推广平台有哪些
  • 网站建设的步骤过程网络营销五个主要手段
  • 免费软件看小说上门龙婿叶辰官网seo优化找哪家做
  • 生鲜b2c网站建设规划书超级外链工具
  • 上海图文设计有限公司重庆seo网站建设
  • 优质的做网站推广赚钱的平台