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

企业网站程序下载seo网站优化怎么做

企业网站程序下载,seo网站优化怎么做,wordpress怎么删除文章,在线教育网站开发软件个人主页:Guiat 归属专栏:算法竞赛真题题解 文章目录 A. 日期统计B. 01串的熵C. 冶炼金属D. 飞机降落E. 接龙数列F. 岛屿个数G. 子串简写H. 整数删除I. 景区导游J. 砍树 正文 总共10道题。 A. 日期统计 【题目】日期统计 【分析】 【答案】235 【AC_…

在这里插入图片描述

个人主页:Guiat
归属专栏:算法竞赛真题题解

在这里插入图片描述

文章目录

  • A. 日期统计
  • B. 01串的熵
  • C. 冶炼金属
  • D. 飞机降落
  • E. 接龙数列
  • F. 岛屿个数
  • G. 子串简写
  • H. 整数删除
  • I. 景区导游
  • J. 砍树

正文

总共10道题。

A. 日期统计

【题目】日期统计

【分析】

【答案】235

【AC_Code】

#include <iostream>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;int a[100] = 
{5, 6, 8, 6, 9, 1, 6, 1, 2, 4, 9, 1, 9, 8, 2, 3, 6, 4, 7, 7,5, 9, 5, 0, 3, 8, 7, 5, 8, 1, 5, 8, 6, 1, 8, 3, 0, 3, 7, 9,2, 7, 0, 5, 8, 8, 5, 7, 0, 9, 9, 1, 9, 4, 4, 6, 8, 6, 3, 3,8, 5, 1, 6, 3, 4, 6, 7, 0, 7, 8, 2, 7, 6, 8, 9, 5, 6, 5, 6,1, 4, 0, 1, 0, 0, 9, 4, 8, 0, 9, 1, 2, 8, 5, 0, 2, 5, 3, 3
}, month[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, ans;void solve()
{for (int m = 1; m <= 12; m ++) for (int d = 1; d <= month[m]; d ++){int data[8] = { 2, 0, 2, 3, m / 10, m % 10, d / 10, d % 10 }, k = 0;for (int i = 0; i < 100; i ++){if (a[i] == data[k]) { k ++; if (k == 8) { ans ++; break; } }}}cout << ans << '\n';
}int main()
{IOS; int _ = 1; // cin >> _;while (_ --) solve();return 0;
}

B. 01串的熵

【题目】01串的熵

【分析】

【答案】11027421

【AC_Code】

#include <iostream>
#include <cmath>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;double n = 23333333, sum;void solve()
{for (int i = 0; i <= n / 2; i ++){sum = 0; sum -= i * (i / n) * log2(i / n) + (n - i) * ((n - i) / n) * log2((n - i) / n);if (sum > 11625907.5 && sum < 11625907.6) { cout << i << '\n'; break; }}
}int main()
{IOS; int _ = 1; // cin >> _;while (_ --) solve();return 0;
}

C. 冶炼金属

【题目】冶炼金属

【分析】

【AC_Code】

#include <iostream>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;int n, a, b, m, M = 2e9;void solve()
{cin >> n;for (int i = 1; i <= n; i ++){cin >> a >> b;int l = a / (b + 1) + 1, r = a / b;m = max(m, l); M = min(M, r);}cout << m << ' ' << M << '\n';
}int main()
{IOS; int _ = 1; // cin >> _;while (_ --) solve();return 0;
}

D. 飞机降落

【题目】飞机降落

【分析】
数据n的范围比较小,考虑暴力搜索。

【AC_Code】

#include <iostream>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;const int N = 15;
int t, n, T[N], D[N], L[N]; bool vis[N];bool dfs(int deep, int time)
{if (deep > n) return true;for (int i = 1; i <= n; i ++){if (vis[i] || T[i] + D[i] < time) continue;vis[i] = true;if (dfs(deep + 1, max(time, T[i]) + L[i])) { vis[i] = false; return true; }vis[i] = false;}return false;
}void solve()
{cin >> t;while (t --){cin >> n; for (int i = 1; i <= n; i ++) cin >> T[i] >> D[i] >> L[i];if (dfs(1, 0)) cout << "YES\n";else cout << "NO\n";}
}int main()
{IOS; int _ = 1; // cin >> _;while (_ --) solve();return 0;
}

E. 接龙数列

【题目】接龙数列

【分析】

【AC_Code】

#include <iostream>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;const int N = 10;
int n, dp[N], maxn; string a;void solve()
{cin >> n;for (int i = 1; i <= n; i ++){cin >> a; int len = a.length();dp[a[len - 1] - '0'] = max(dp[a[len - 1] - '0'], dp[a[0] - '0'] + 1);}for (int i = 0; i < 10; i ++) maxn = max(maxn, dp[i]);cout << n - maxn << '\n';
}int main()
{IOS; int _ = 1; // cin >> _;while (_ --) solve();return 0;
}

F. 岛屿个数

【题目】岛屿个数

【分析】

【AC_Code】

#include <iostream>
#include <cstdio>
#define IOS ios :: sync_with_stdio(0); cin.tie(0);using namespace std;const int maxn = 55;
int T, M, N, a[maxn][maxn];void dfs_sea(int x, int y)
{int dx[] = { 0, 0, 1, 1, 1, -1, -1, -1 },dy[] =  { 1, -1, 0, 1, -1, 0, 1, -1 };if (x < 0 || x > M + 1 || y < 0 || y > N + 1) return;if (a[x][y] != 0) return;a[x][y] = 2;for (int i = 0; i < 8; ++i) dfs_sea(x + dx[i], y + dy[i]);
}void dfs_island(int x, int y)
{int dx[] = { 1, -1, 0, 0 },dy[] = { 0, 0, 1, -1 };if (x < 0 || x > M + 1 || y < 0 || y > N + 1) return;if (a[x][y] != 1) return;a[x][y] = 3;for (int i = 0; i < 4; ++ i) dfs_island(x + dx[i], y + dy[i]);
}void solve()
{cin >> T;while (T --){cin >> M >> N;for (int i = 0; i < N + 2; ++ i) { a[0][i] = 0, a[M + 1][i] = 0; }for (int i = 1; i < M + 1; ++ i) { a[i][0] = 0, a[i][N + 1] = 0; }for (int i = 1; i < M + 1; ++ i) for (int j = 1; j < N + 1; ++ j) scanf("%1d", &a[i][j]);dfs_sea(0, 0); int cnt = 0;for (int i = 0; i < M + 2; ++ i) for (int j = 0; j < N + 2; ++ j){if (a[i][j] == 1 && (i > 0 && a[i - 1][j] == 2)) dfs_island(i, j), cnt ++;}cout << cnt << '\n';
//      for (int i = 0; i < M + 2; i ++) for (int j = 0; j < N + 2; j ++)
//      {
//      	printf("%ld", a[i][j]); if (j == N + 1) cout << '\n';
//      }}
}int main()
{// IOS;int _ = 1; // cin >> _;while (_ --) solve();return 0;
}

G. 子串简写

【题目】子串简写

【分析】

  • 两个计数变量c1_sum和cnt比较大,得开long long。
  • 题干出现字符串的两个边界c1,c2,考虑用滑动窗口解题。
  • 使用两个指针i,j,类似于快慢指针,i从0到S.length() - K,j从K - 1到S.length() - 1。
  • 对于每个窗口,如S[i] == c1,则c1_sum加1;
  • 如S[j] = c2,则将c1_sum的值累加到cnt。
  • 最后输出总组合数cnt。

【AC_Code】

#include <iostream>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;
using ll = long long;int K; string S; char c1, c2; ll c1_sum, cnt;void solve()
{cin >> K >> S >> c1 >> c2;for (int i = 0, j = K - 1; j < S.length(); i ++, j ++){if (S[i] == c1) c1_sum ++;if (S[j] == c2) cnt += c1_sum;}cout << cnt << '\n';
}int main()
{IOS; int _ = 1; // cin >> _;while (_ --) solve();return 0;
}

H. 整数删除

【题目】整数删除

【分析】

  • 考察优先队列和双向链表。

【AC_Code】

I. 景区导游

【题目】 景区导游

【分析】

【AC_Code】

J. 砍树

【题目】砍树

【分析】

【AC_Code】

结语
感谢您的阅读!期待您的一键三连!欢迎指正!

在这里插入图片描述

http://www.dtcms.com/wzjs/188044.html

相关文章:

  • 在小型网站建设小组中的基本徐州seo企业
  • 烟台商城网站建设大数据营销是什么
  • 江苏建设监理协会网站西安百度
  • 茶叶网站源码 下载郴州seo网络优化
  • 企业门户网站云服务器配置要求百度电商平台
  • php网站运行很慢软文发布推广平台
  • 广州免费核酸检测地点相城seo网站优化软件
  • 商城网站建设怎么收费搜索引擎优化包括哪些方面
  • 网站关键词布局实操西安优化seo托管
  • 昆山市建设局网站苏州网站建设
  • 南通网站建设方案开发网页在线代理翻墙
  • 网站建设包含seo实战视频
  • WordPress拍卖模板深圳seo网站推广方案
  • 企业网站用什么建站最快关键词查询网
  • wordpress google广告重庆网站seo公司
  • 流线型的网站建设seo网站培训班
  • 哈尔滨建站系统点击查看上海牛巨微seo优化
  • 程序外包价格seo软件视频教程
  • 温江网站建设各大搜索引擎网址
  • 网站描文本整站优化提升排名
  • 给文字做网站链接百度网盘app下载安装官方免费下载
  • 网站建设日记传统营销与网络营销的区别
  • 沈阳口碑最好的男科医院长沙靠谱seo优化
  • 北京顺义有网站建设公司吗网络广告网站
  • 丽水网站建设公司排名厦门网站建设
  • 静态网站模板古典个人怎么开跨境电商店铺
  • 网站开发实训报告模板百度seo教程网
  • 电子商务网站建设收益淮北网络推广
  • 网站内容添加网络销售公司经营范围
  • 网站引导页怎么做的最近韩国电影片