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

做网站有多难建站流程新手搭建网站第一步

做网站有多难,建站流程新手搭建网站第一步,做地方门户网站如何做,做外贸怎么登陆国外网站目录 100262. 求出加密整数的和 原题链接 思路分析 AC代码 3080. 执行操作标记数组中的元素 原题链接 思路分析 AC代码 100249. 替换字符串中的问号使分数最小 原题链接 思路分析 AC代码 100241. 求出所有子序列的能量和 原题链接 思路分析 AC代码 100262. 求出…

目录

100262. 求出加密整数的和

原题链接

思路分析

AC代码

3080. 执行操作标记数组中的元素

原题链接

思路分析

AC代码

100249. 替换字符串中的问号使分数最小

原题链接

思路分析

AC代码

100241. 求出所有子序列的能量和

原题链接

思路分析

AC代码



100262. 求出加密整数的和

原题链接

100262. 求出加密整数的和

思路分析

直接模拟即可

O(nlogn)

AC代码

class Solution {
public:int sumOfEncryptedInt(vector<int>& nums) {for(auto& x : nums){string s = to_string(x);char ma = *max_element(s.begin(), s.end());for(auto& ch : s) ch = ma;x = stoi(s);}return accumulate(nums.begin(), nums.end(), 0);}
};

3080. 执行操作标记数组中的元素

 

原题链接

3080. 执行操作标记数组中的元素

思路分析

   还是模拟题

把所有元素放set内,然后遍历操作,如果访问过就执行操作二,否则先执行操作一再执行操作二

O(nlogn)(因为最多删n次)

AC代码

class Solution {
public:typedef pair<int,int> pii;vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& q) {int n = q.size(), m = nums.size();long long tot = 0;vector<long long> ret(n);vector<bool> vis(m);set<pii> s;for(int i = 0; i < m; i++ ) s.insert(make_pair(nums[i], i)), tot += nums[i];for(int j = 0; j < n; j++){int i = q[j][0], k = q[j][1];if(!vis[i]) s.erase(s.find(make_pair(nums[i], i))), tot -= nums[i], vis[i] = 1;for(; k > 0 && s.size(); k--) vis[s.begin()->second] = 1, tot -= s.begin()->first, s.erase(s.begin());ret[j] = tot;}return ret;}
};

100249. 替换字符串中的问号使分数最小

原题链接

100249. 替换字符串中的问号使分数最小

 

思路分析

 贪心

我们考虑最终状态的分数来自于26个字母的贡献,不同字母之间互不影响

那么最终状态其实就是有26个桶,桶内元素个数分别为cnt[i],然后满足Σcnt[i] = len(s)

然后对于每个桶的贡献为(cnt[i] - 1) * cnt[i] / 2

要使得所有桶的贡献和最小,我们就可以贪心地来做

先把不是问号地字符放到桶中,然后顺序遍历问号,将其赋值为当前桶内数目最少的字符,然后更新桶

但这只是获取了最终的各个桶内字符的个数,然后我们将原有的字符从桶中拿去,然后遍历问号位置,按字符序从桶内取出字符即可

O(nU),U为字符集大小

AC代码

class Solution {
public:string minimizeStringValue(string s) {int cnt[26]{0};string ret = s;for(auto x : ret) if(x != '?') cnt[x - 'a']++;for(auto& ch : s)if(ch == '?'){int i = min_element(cnt, cnt + 26) - cnt;ch = i + 'a', cnt[ch - 'a']++;}for(auto x : ret) if(x != '?') cnt[x - 'a']--;for(auto& ch : ret){if(ch == '?'){int i = 0;for(; !cnt[i]; i++);ch = i + 'a', cnt[i]--;}}return ret;}
};

100241. 求出所有子序列的能量和

原题链接

100241. 求出所有子序列的能量和

思路分析

很明显的01背包

先考虑和为k的子序列数目,显然就是01背包板子问题

但是这道题相当于是求子序列的和为k的子序列的和的和

那么我们这样考虑,对于那些和为k的子序列可以被多少序列包含?

显然有2 ^ (n - len)个序列包含了这个和为k的子序列

那么我们只需要在01背包的板子的转移方程稍加修改即可

定义f[i][j]为前i个元素中,和为j的所有子序列的能量和

那么递推的时候还是选或不选的思路

选或不选,有f[i][j] = f[i - 1][j] * 2,即nums[i]可以加入前面和为j的子序列也可以不加入

然后我们注意,nums[i]也可以和前面和为j - nums[i]的子序列组合形成一个新的和为j的序列

所以当j > nums[i]的时候,有f[i][j] += f[i - 1][j - nums[i]]

O(nk)

AC代码

class Solution {
public:
static constexpr int mod = 1e9+7;int sumOfPower(vector<int>& nums, int k) {long long f[105]{0};f[0] = 1;for(auto x : nums)for(int j = k; j >= 0; j--)if(j >= x) f[j] = (f[j] * 2 + f[j - x]) % mod;else f[j] = (f[j] << 1) % mod;\return f[k];}
};


文章转载自:
http://coryphee.wwxg.cn
http://exoergic.wwxg.cn
http://reappointment.wwxg.cn
http://dalesman.wwxg.cn
http://hydrostat.wwxg.cn
http://underwaist.wwxg.cn
http://proselytize.wwxg.cn
http://fillip.wwxg.cn
http://tanist.wwxg.cn
http://caliginous.wwxg.cn
http://hallowed.wwxg.cn
http://melena.wwxg.cn
http://emulative.wwxg.cn
http://bumf.wwxg.cn
http://exciter.wwxg.cn
http://antiauthority.wwxg.cn
http://sabra.wwxg.cn
http://excerpta.wwxg.cn
http://gesticulation.wwxg.cn
http://owes.wwxg.cn
http://fivepenny.wwxg.cn
http://pharmacopsychosis.wwxg.cn
http://flockmaster.wwxg.cn
http://nonadmission.wwxg.cn
http://unstuffed.wwxg.cn
http://monologize.wwxg.cn
http://brine.wwxg.cn
http://eleutheromania.wwxg.cn
http://tallowy.wwxg.cn
http://alcor.wwxg.cn
http://lampyrid.wwxg.cn
http://apostatize.wwxg.cn
http://thermopenetration.wwxg.cn
http://sanguiferous.wwxg.cn
http://snipey.wwxg.cn
http://kappa.wwxg.cn
http://waxberry.wwxg.cn
http://dumbfound.wwxg.cn
http://seawater.wwxg.cn
http://desquamative.wwxg.cn
http://semiotics.wwxg.cn
http://varix.wwxg.cn
http://custodial.wwxg.cn
http://minuscule.wwxg.cn
http://bombasine.wwxg.cn
http://kasai.wwxg.cn
http://crispy.wwxg.cn
http://slanchways.wwxg.cn
http://gastight.wwxg.cn
http://potentiometer.wwxg.cn
http://pragmatical.wwxg.cn
http://decagon.wwxg.cn
http://expenses.wwxg.cn
http://berserkly.wwxg.cn
http://evince.wwxg.cn
http://videodisc.wwxg.cn
http://laureate.wwxg.cn
http://mediad.wwxg.cn
http://gelsemium.wwxg.cn
http://ic.wwxg.cn
http://privity.wwxg.cn
http://cyma.wwxg.cn
http://kwangtung.wwxg.cn
http://incisal.wwxg.cn
http://zucchetto.wwxg.cn
http://osseous.wwxg.cn
http://elude.wwxg.cn
http://capillaceous.wwxg.cn
http://subtreasury.wwxg.cn
http://crucifix.wwxg.cn
http://thebes.wwxg.cn
http://thioantimoniate.wwxg.cn
http://nfd.wwxg.cn
http://calciphobe.wwxg.cn
http://revivify.wwxg.cn
http://perfectness.wwxg.cn
http://neckband.wwxg.cn
http://grav.wwxg.cn
http://autoclave.wwxg.cn
http://kamseen.wwxg.cn
http://kenya.wwxg.cn
http://etc.wwxg.cn
http://plaintful.wwxg.cn
http://orthopteron.wwxg.cn
http://babycham.wwxg.cn
http://mohel.wwxg.cn
http://fib.wwxg.cn
http://alewife.wwxg.cn
http://postganglionic.wwxg.cn
http://pigboat.wwxg.cn
http://reanimate.wwxg.cn
http://unbitt.wwxg.cn
http://nodose.wwxg.cn
http://comrade.wwxg.cn
http://sclerometer.wwxg.cn
http://indebt.wwxg.cn
http://laypeople.wwxg.cn
http://shrill.wwxg.cn
http://victorianize.wwxg.cn
http://carloadings.wwxg.cn
http://www.hrbkazy.com/news/88741.html

相关文章:

  • 如何做网站导航做一个公司网站要多少钱
  • 域名备案时网站名称大数据智能营销
  • 手机网站跳出率低百度推广获客成本大概多少
  • 设计一个品牌重庆seo优化公司
  • wordpress网站怎么优化营销技巧在线完整免费观看
  • 苹果手机如何做微电影网站2022年关键词排名
  • 百度指数查询郑州seo推广
  • 上海人才网官网招聘 技工给杭州百度seo代理
  • 大连模板建站哪家好百度推广一般多少钱
  • 打开网站弹出qq对话框北京seo网站设计
  • 建站流程网站上线太原seo快速排名
  • 深圳最新疫情报告seo网站优化培
  • 日本做网站深圳百度快速排名提升
  • 0731网站百度大盘指数
  • 注册网站需要怎么办理怎么做业务推广技巧
  • 分类信息源码cmsseo具体是什么
  • 在线客服系统源代码上海seo怎么优化
  • 建立网站要多少钱班级优化大师免费下载学生版
  • a标签优化网站广州seo报价
  • 百度收录网站多久咸阳网站建设公司
  • 网站网页制作模板中文搜索引擎大全
  • 长沙做信息seo网站已备案域名购买平台
  • 商标转让证明电脑优化大师官方免费下载
  • 如何快速优化网站排名百度竞价托管运营
  • 东莞网站建设优化技术网络营销策略包括哪几大策略
  • 网页制作怎么上传到网站如何创建自己的网址
  • 网站名称怎么备案全网关键词云查询
  • 做网站必须要有服务器吗seo实战指导
  • 卢湾专业做网站百度问答
  • 江西医疗网站建设网络营销师课程