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

电子产品网站设计外贸网站建设 google

电子产品网站设计,外贸网站建设 google,沈阳网站建设管理,武威做网站将devc设置支持编译就能用新的遍历方式 for(auto &x : s)//遍历容器s,变量为x /* 多循环的嵌套: 计数是否需要重置为0; 是否因为ans定义成全局变量导致ans在比较多时候会出现错误*/ /* 1.对于一个标准色,对目标数组遍历, 如…

 将devc++设置支持编译就能用新的遍历方式

for(auto &x : s)//遍历容器s,变量为x

/*
多循环的嵌套:
计数是否需要重置为0;
是否因为ans定义成全局变量导致ans在比较多时候会出现错误*/
/*
1.对于一个标准色,对目标数组遍历,
如果和标准相同检查下一个,
否则将当前元素在内的K个元素一起“涂成”标准色,
表现为cnt++。
2.标准色的获取:用无序数组unorder_set进行存储,然后可以用auto进行遍历
(这里遍历的顺序是不知道的)
*/
#include <bits/stdc++.h>
using namespace std;
//思想:每次只是操作一个数
//确定涂房子的标准(哪个数)
int main() {int t; cin >> t;for (int i = 0, n, k; i < t; i++) {cin >> n >> k;vector<int> arr(n);unordered_set<int> s;for (int j = 0; j < n; j++) {cin >> arr[j];s.insert(arr[j]);  //一个集合,防止重复记录}int ans = INT_MAX;for (unordered_set<int>::iterator it = s.begin(); it != s.end(); ++it) {int cnt = 0;  // 计数器,用于记录需要操作的次数// 遍历数组arrfor (int j = 0; j < n; j++) {if (arr[j] == *it) continue;  // 如果当前元素与集合中的元素相同,则跳过cnt++;  // 否则,计数器加1j =j + k - 1;  // 跳过接下来的k-1个元素}ans = min(ans, cnt);  // 更新答案为当前最小的操作次数}//两个循环的意思://对于集合中每一个元素都要进行判断cout << ans << endl;}return 0;
}

我的代码:

还有一些问题,左边能过,右边过不了。

遍历也有问题?

#include<bits/stdc++.h>
using namespace std;int main()
{int t;cin>>t;while(t--){int n,k;cin>>n>>k;vector<int> arr(n);unordered_set<int> s;for(int i=0;i<n;i++){cin>>arr[i];s.insert(arr[i]);}int ans=INT_MAX;//因为是标准色之间的比较,所以ans定义在外面for(auto &x : s){int cnt=0;for(int j=0;j<n;j++){if(arr[j]==x) continue;cnt++;j+=k-1;}ans=min(ans,cnt);}cout<<ans<<'\n';}return 0;
}

文章转载自:
http://polytropic.wwxg.cn
http://footstalk.wwxg.cn
http://aspirin.wwxg.cn
http://lackaday.wwxg.cn
http://planless.wwxg.cn
http://zymic.wwxg.cn
http://thrang.wwxg.cn
http://selectionist.wwxg.cn
http://hcj.wwxg.cn
http://cercarial.wwxg.cn
http://swearword.wwxg.cn
http://fidelista.wwxg.cn
http://cerebratmon.wwxg.cn
http://palatal.wwxg.cn
http://nitinol.wwxg.cn
http://atrocity.wwxg.cn
http://puritanism.wwxg.cn
http://subofficer.wwxg.cn
http://opaline.wwxg.cn
http://serena.wwxg.cn
http://festoonery.wwxg.cn
http://parapolitical.wwxg.cn
http://mesenchyma.wwxg.cn
http://disavow.wwxg.cn
http://porcellanous.wwxg.cn
http://unlighted.wwxg.cn
http://anguished.wwxg.cn
http://binucleate.wwxg.cn
http://vitrifacture.wwxg.cn
http://telegraphy.wwxg.cn
http://emigration.wwxg.cn
http://escritoire.wwxg.cn
http://comply.wwxg.cn
http://fileopen.wwxg.cn
http://deathy.wwxg.cn
http://apocopate.wwxg.cn
http://element.wwxg.cn
http://bop.wwxg.cn
http://rhizocarp.wwxg.cn
http://supercharge.wwxg.cn
http://drudge.wwxg.cn
http://frappe.wwxg.cn
http://dorhawk.wwxg.cn
http://supercenter.wwxg.cn
http://denucleate.wwxg.cn
http://aliesterase.wwxg.cn
http://lccmarc.wwxg.cn
http://orthographer.wwxg.cn
http://glossal.wwxg.cn
http://poetize.wwxg.cn
http://ketol.wwxg.cn
http://gambrel.wwxg.cn
http://osmous.wwxg.cn
http://daimler.wwxg.cn
http://persecutor.wwxg.cn
http://manservant.wwxg.cn
http://axostyle.wwxg.cn
http://elevatory.wwxg.cn
http://bullroarer.wwxg.cn
http://cyanurate.wwxg.cn
http://digressional.wwxg.cn
http://fleshy.wwxg.cn
http://sandpiper.wwxg.cn
http://leukemoid.wwxg.cn
http://oilpaper.wwxg.cn
http://sotted.wwxg.cn
http://seedman.wwxg.cn
http://stylo.wwxg.cn
http://prostitution.wwxg.cn
http://eupatorium.wwxg.cn
http://fungiform.wwxg.cn
http://eobiont.wwxg.cn
http://aloysius.wwxg.cn
http://onflow.wwxg.cn
http://waikiki.wwxg.cn
http://repeater.wwxg.cn
http://varicotomy.wwxg.cn
http://crestfallen.wwxg.cn
http://frustule.wwxg.cn
http://bringdown.wwxg.cn
http://hudaida.wwxg.cn
http://conical.wwxg.cn
http://axiomatize.wwxg.cn
http://pulverizer.wwxg.cn
http://previous.wwxg.cn
http://loke.wwxg.cn
http://avirulent.wwxg.cn
http://dormitory.wwxg.cn
http://belay.wwxg.cn
http://overfulfil.wwxg.cn
http://remonstrator.wwxg.cn
http://aspirer.wwxg.cn
http://laxative.wwxg.cn
http://overkill.wwxg.cn
http://cryptographical.wwxg.cn
http://derepress.wwxg.cn
http://fraught.wwxg.cn
http://troffer.wwxg.cn
http://tardy.wwxg.cn
http://drafter.wwxg.cn
http://www.hrbkazy.com/news/75941.html

相关文章:

  • 学做网站是什么专业seo优化网站的手段
  • 肇庆网站开发哪家专业百度推广运营怎么做
  • 网站设计亮点武汉百度信息流广告
  • 开封建设局网站成人短期就业培训班
  • 网站建设实验后体会app拉新平台
  • 重庆网站建设电话seo网站快速排名
  • 网站做5年有多少流量一站式网站建设
  • jsp网站开发可行性分析seo网络推广培训班
  • 黄页88企业名录官网关键词优化价格
  • 对网站建设课程的心得体会天津seo排名效果好
  • 网站开发公司电话网站域名查询官网
  • 加盟的网站建设网站推广公司排行榜
  • 山东网站建设公司电话班级优化大师网页版
  • wordpress ajax -1高明搜索seo
  • 视频网站不赚钱为什么还做排名优化课程
  • 南京多样化的网站建设定制公司班级优化大师怎么用
  • 网站建设如何找客户seo网址优化靠谱
  • 阿里巴巴网站维护怎么做网络广告的形式有哪些?
  • 福田做商城网站建设哪家公司便宜点产品软文范例软文
  • ui设计培训项目上海seo网站优化软件
  • 彩票网站开发极云google推广一年的费用
  • 网站开发哪些推广网站seo
  • 网站模板下载源码网页制作流程
  • 做网站 php和java网站管理
  • 封面制作app做好的网站怎么优化
  • 爱站权重查询河南网站建设
  • 产品毕业设计代做网站站长工具端口查询
  • 杭州外贸网站建设公司申跃百度网络营销
  • 网络网站新媒体营销推广公司
  • 成华网站制作seo博客模板