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

服务器cpu怎么优化关键词

服务器cpu,怎么优化关键词,dns解析失败登录不了网站,山西省建设工程信息网蓝桥杯小白赛 ​​​​​​​3.小蓝的金牌梦【算法赛】 - 蓝桥云课 (lanqiao.cn) 数组长度为质数,最大的子数组和 素数 前缀和 #include "bits/stdc.h" using namespace std; #define int long long #define N 100010 int ans[N];int s[N];vector&l…

蓝桥杯小白赛 

​​​​​​​3.小蓝的金牌梦【算法赛】 - 蓝桥云课 (lanqiao.cn)

数组长度为质数,最大的子数组和

素数 + 前缀和

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define N 100010
int ans[N];int s[N];vector<int> prime;
bool is_prime[N];void Era(int n) {is_prime[0] = is_prime[1] = true;for (int i = 2; i <= n; ++i) {if (!is_prime[i]) {prime.push_back(i);if ((int)i * i > n) continue;for (int j = i * i; j <= n; j += i) is_prime[j] = true;}}
}
void Eratosthenes(int n) {is_prime[0] = is_prime[1] = false;for (int i = 2; i <= n; ++i) is_prime[i] = true;for (int i = 2; i <= n; ++i) {if (is_prime[i]) {prime.push_back(i);if ((long long)i * i > n) continue;for (int j = i * i; j <= n; j += i)// 因为从 2 到 i - 1 的倍数我们之前筛过了,这里直接从 i// 的倍数开始,提高了运行速度is_prime[j] = false;  // 是 i 的倍数的均不是素数}}
}
signed main() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);int maxn = -1e18;;int n, t;cin >> n;for (int i = 1; i <= n; ++i) {cin >> t;s[i] = s[i-1] + t;}Era(n);for (int i = 0; i < prime.size(); ++i) {for (int j = prime[i]; j <= n; ++j) {maxn = max(maxn, s[j]-s[j-prime[i]]);}}// for (auto x:prime) {//   cout << x << ' ';// }cout << maxn << endl;return 0;
}

4.合并石子加强版【算法赛】 - 蓝桥云课 (lanqiao.cn)

数学

a*b + (a+b)*c == a*b + a* c + b*c == b*c + (b+c)*a

#include "bits/stdc++.h"
using namespace std;
#define int unsigned long long
signed main()
{ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);int n, t, sum=0, free=0;cin>>n;// cin >> sum;for(int i=0;i<n;++i){cin >> t;free += t*sum;sum += t;// free += ;}cout << free << endl;return 0;
}

力扣双周赛

100130. 找到两个数组中的公共元素 - 力扣(LeetCode)

看错题意

class Solution {
public:vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {unordered_set<int> set1(nums1.begin(), nums1.end());unordered_set<int> set2(nums2.begin(), nums2.end());vector<int> ans(2);for (int x: nums1) ans[0] += set2.count(x);for (int x: nums2) ans[1] += set1.count(x);return ans;}
};

 总结

set1(nums1.begin(), nums2.end())  容器可以直接根据另一个容器初始化

set.count(x)         如果找到数值为x的元素,返回1;找不到,返回0

100152. 消除相邻近似相等字符 - 力扣(LeetCode)

 看成首位也需要判断(环)

贪心,贪第二个

class Solution {
public:int removeAlmostEqualCharacters(string word) {int cnt = 0;for (int i = 0; i < word.size() - 1; ++i){if (abs((word[i]-word[i+1])) <= 1) {// word[i+1] = 'A';++i;++cnt;}}return cnt;}
};

2958. 最多 K 个重复元素的最长子数组 - 力扣(LeetCode)

暴力超时

子数组:1 哈希表 2 滑动窗口

class Solution {
public:int maxSubarrayLength(vector<int>& nums, int k) {int ans = 0, left = 0;unordered_map<int, int> cnt;for (int right = 0; right < nums.size(); ++right) {++cnt[nums[right]];while (cnt[nums[right]] > k) {--cnt[nums[left++]];}ans = max(ans, right - left + 1);}return ans;}
};

本周计划:

盛最多水的容器 接雨水_哔哩哔哩_bilibili

同向双指针 滑动窗口【基础算法精讲 03】_哔哩哔哩_bilibili

2958. 最多 K 个重复元素的最长子数组 - 力扣(LeetCode) 

2560. 打家劫舍 IV - 力扣(LeetCode)

 

http://www.hkea.cn/news/917008/

相关文章:

  • 河源哪有做网站网页模板设计
  • 手机网站可以做英文版本吗近三天时政热点
  • 怎么做网站游戏网络优化排名培训
  • ic外贸网站建设黑帽seo技巧
  • 实业有限公司网站怎么做百度一下了你就知道官网
  • 企业电子商务网站推广平台有哪些渠道
  • 本地用织梦做网站百度的网站网址
  • 基础展示营销型型网站新闻发稿平台有哪些
  • 做游戏赚钱的网站最新新闻热点事件2022
  • 商务网站建设哪家好推广代理公司
  • 自己做网站是否要买云主机西安百度提升优化
  • 成都注册公司哪个区好分析网站推广和优化的原因
  • 模板建站杭州seo泽成
  • 济南网站建设公司川芎网络怎么注册自己的网址
  • linux下安装wordpress关键词优化排名查询
  • wordpress手机网站怎么做中央电视台一套广告价目表
  • 百家号如何给网站做推广推广方案是什么
  • 西安三网合一网站建设产品线上推广方案
  • 2023年免费b站入口百度网站优化
  • 响应式网站建设有利于seo网站发布与推广方案
  • 网页制作教程课件seo推广排名重要吗
  • 小规模纳税人企业所得税怎么征收广州seo招聘
  • 济南企业自助建站网络营销策划公司
  • iis 新建网站 要登录温州seo推广外包
  • 个人想做企业网站备案惠州seo代理商
  • 做公务员题的网站口红的推广软文
  • 福州网站建设 联系yanktcn 04上海百网优seo优化公司
  • 网站备案号如何获得网站建设营销推广
  • 物流网站开发公司西安 做网站
  • 商务信息网站怎么做网络视频营销策略有哪些