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

ftp给网站做备份百度官方认证

ftp给网站做备份,百度官方认证,怎么做加密货币网站,洛阳网站建设价格低目录 循环枚举 P2241 统计方形(数据加强版) P2089 烤鸡 P1618 三连击(升级版) 子集枚举 P1036 [NOIP2002 普及组] 选数 P1157 组合的输出 排列枚举 P1706 全排列问题 P1088 [NOIP2004 普及组] 火星人 循环枚举 顾名思…

目录

循环枚举

P2241 统计方形(数据加强版)

P2089 烤鸡

P1618 三连击(升级版)

子集枚举

P1036 [NOIP2002 普及组] 选数

P1157 组合的输出

排列枚举 

P1706 全排列问题

P1088 [NOIP2004 普及组] 火星人


循环枚举

顾名思义,通过for循环或者while循环枚举所有可能方案。 

P2241 统计方形(数据加强版)

很显然这是一道找规律的题目:正方形和长方形的唯一区别在于长宽是否相等,根据此条件可以统计矩形个数,先研究规律:

	for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++)

首先是横着的长方形,宽始终为1,长不断发生改变,可以看出长为2的时候,第一行个数为6个,总共有6 x 6个,长为3的时候,总共有6 x 5个……以上述循环条件来看可以得出一个规律:

长发生变化后的矩形总个数为m * ( n - j + 1)个。

第二看纵向宽发生改变,长重置为1,长为1,宽为2的时候,第一行个数为7个,总共有5 x 7 个,长为2,宽为2的时候 第一行个数为6个,共有5 x 6个……综上所述,可以得出普遍规律:
( m - i + 1) * ( n - j + 1)为每次发生长变化或者宽变化的矩形总个数,又因为长方形与正方形唯一区别是长宽是否相等,因此代码如下:

#include<iostream>
using namespace std;
int main()
{int n, m; cin >> n >> m;long count1 = 0, count2 = 0;for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++)if (i == j)count1 += (m - i + 1) * (n - j + 1);elsecount2 += (m - i + 1) * (n - j + 1);cout << count1 << ' ' << count2 << endl;return 0;
}

P2089 烤鸡

 暴力枚举,用十个循环解决此问题,注意:n如果小于10或者大于30直接输出0即可,原因是十种配料之和最小为10,最大为30。

#include <iostream>
using namespace std;int main()
{int n, count = 0; cin >> n;if (n < 10 || n > 30){cout << 0 << endl;return 0;}else{for (int a = 1; a <= 3; a++)for (int b = 1; b <= 3; b++)for (int c = 1; c <= 3; c++)for (int d = 1; d <= 3; d++)for (int e = 1; e <= 3; e++)for (int f = 1; f <= 3; f++)for (int g = 1; g <= 3; g++)for (int h = 1; h <= 3; h++)for (int i = 1; i <= 3; i++)for (int j = 1; j <= 3; j++)if (a + b + c + d + e + f + g + h + i + j == n)count++;cout << count << endl;for (int a = 1; a <= 3; a++)for (int b = 1; b <= 3; b++)for (int c = 1; c <= 3; c++)for (int d = 1; d <= 3; d++)for (int e = 1; e <= 3; e++)for (int f = 1; f <= 3; f++)for (int g = 1; g <= 3; g++)for (int h = 1; h <= 3; h++)for (int i = 1; i <= 3; i++)for (int j = 1; j <= 3; j++)if (a + b + c + d + e + f + g + h + i + j == n)cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << ' ' << g << ' ' << h << ' ' << i << ' ' << j << ' ' << endl;}return 0;
}

P1618 三连击(升级版)

 本人比较喜欢用stl接口,下面附上代码,注意:输入123,456,789,输出123,456,789

#include<bits/stdc++.h>
using namespace std;int a, b, c, t1, t2, t3; string def;int main()
{cin >> a >> b >> c;for (int i = 1; i <= 1000 / c; i++) //记得从1开始  原因:123,456,789满足{t1 = i * a; t2 = i * b; t3 = i * c;string s1 = to_string(t1), s2 = to_string(t2), s3 = to_string(t3);string tmp; tmp += s1; tmp += s2; tmp += s3;sort(tmp.begin(), tmp.end()); //排序auto it = unique(tmp.begin(), tmp.end()); //去重操作tmp.resize(distance(tmp.begin(), it)); //计算两个迭代器之间的距离if (tmp.size() == 9 && tmp[0] == '1'){cout << s1 << ' ' << s2 << ' ' << s3 << endl;def = tmp;}}if(def.size()==0) //空的说明都不满足cout << "No!!!" << endl;return 0;
}

子集枚举

P1036 [NOIP2002 普及组] 选数

这是一道简单的模拟题,枚举出所有可能情况,不会超过规定时间的,以下附上k<=3的代码,如果需要更大的k,继续仿照写即可。

#include <bits/stdc++.h>
using namespace std;int n, k;bool is_prinum(int x)
{for (int i = 2; i <= sqrt(x); i++)if (x % i == 0)return false;return true;
}int main()
{cin >> n >> k;vector<int> arr(n), pri;for (int i = 0; i < n; i++)cin >> arr[i];int count = 0;for (int i = 0; i < n; i++){int tmp = arr[i];if (is_prinum(tmp) && k == 1)count++;if (k == 1)continue;for (int j = i + 1; j < n; j++){int tmp = arr[i] + arr[j];if (is_prinum(tmp) && k == 2)count++;if (k == 2)continue;for (int z = j + 1; z < n; z++){int tmp = arr[i] + arr[j] + arr[z];if (is_prinum(tmp) && k == 3)count++;if (k == 3)continue;}}}cout << count << endl;return 0;
}

P1157 组合的输出

与上面一题类似,也是求子集,直接for循环叠加:,下面只举例到3:

#include <bits/stdc++.h>
using namespace std;int n, k;int main()
{cin >> n >> k;vector<string> arr(n), ans;for (int i = 0; i < n; i++)arr[i] = to_string(i + 1);for (int i = 0; i < n; i++){if (k == 1){cout << setw(3) << stoi(arr[i]) << endl;continue;}for (int j = i + 1; j < n; j++){if (k == 2){cout << setw(3) << arr[i] << setw(3) << arr[j] << endl;continue;}for (int z = j + 1; z < n; z++){if (k == 3){cout << setw(3) << arr[i] << setw(3) << arr[j] << setw(3) << arr[z] << endl;continue;}}}}return 0;
}

排列枚举 

P1706 全排列问题

本题可以点击此链接看我另一篇文章,其中解释了如何使用stl库的函数解决该问题。


P1088 [NOIP2004 普及组] 火星人

本题不过多赘述,与上题一样也是stl的使用,以下为代码:

#include<bits/stdc++.h>
using namespace std;int main()
{int n, m; cin >> n >> m;vector<int> arr(n);for (int i = 0; i < n; i++)cin >> arr[i];for (int j = 1; j <= m; j++)next_permutation(arr.begin(), arr.end());for (auto e : arr)cout << e << ' ';return 0;
}

文章转载自:
http://dinncooutfly.bkqw.cn
http://dinncomedullary.bkqw.cn
http://dinncopastie.bkqw.cn
http://dinncointerfluve.bkqw.cn
http://dinncocommonweal.bkqw.cn
http://dinncosickle.bkqw.cn
http://dinncoevillooking.bkqw.cn
http://dinncoparasite.bkqw.cn
http://dinncoblob.bkqw.cn
http://dinncoalecto.bkqw.cn
http://dinncofish.bkqw.cn
http://dinncodereliction.bkqw.cn
http://dinncomicrospecies.bkqw.cn
http://dinncopolarizer.bkqw.cn
http://dinncoomnimane.bkqw.cn
http://dinncoserotonergic.bkqw.cn
http://dinncoarpnet.bkqw.cn
http://dinncocynologist.bkqw.cn
http://dinncoflawless.bkqw.cn
http://dinncorhythm.bkqw.cn
http://dinncominbar.bkqw.cn
http://dinncoideaed.bkqw.cn
http://dinncoparing.bkqw.cn
http://dinncokokobeh.bkqw.cn
http://dinncoregulon.bkqw.cn
http://dinncoethlyn.bkqw.cn
http://dinncoenumerable.bkqw.cn
http://dinncogamester.bkqw.cn
http://dinncoweka.bkqw.cn
http://dinncoalienage.bkqw.cn
http://dinncougc.bkqw.cn
http://dinncotemplar.bkqw.cn
http://dinncopreservatize.bkqw.cn
http://dinncojeroboam.bkqw.cn
http://dinncoinfrared.bkqw.cn
http://dinncospindleful.bkqw.cn
http://dinncoautocrat.bkqw.cn
http://dinnconegrophobia.bkqw.cn
http://dinncoparlement.bkqw.cn
http://dinncosheen.bkqw.cn
http://dinncosolubilize.bkqw.cn
http://dinncoindisposition.bkqw.cn
http://dinncosuperlunary.bkqw.cn
http://dinncounglove.bkqw.cn
http://dinncogeraniol.bkqw.cn
http://dinncotraversing.bkqw.cn
http://dinncounderemployed.bkqw.cn
http://dinncowrangler.bkqw.cn
http://dinncochemisette.bkqw.cn
http://dinncoboarder.bkqw.cn
http://dinncobathless.bkqw.cn
http://dinncopassthrough.bkqw.cn
http://dinncopuncher.bkqw.cn
http://dinncopokelogan.bkqw.cn
http://dinncosamnite.bkqw.cn
http://dinncotrichinelliasis.bkqw.cn
http://dinncoethnological.bkqw.cn
http://dinncolendable.bkqw.cn
http://dinncospall.bkqw.cn
http://dinncochordal.bkqw.cn
http://dinncoparliamental.bkqw.cn
http://dinncodebouche.bkqw.cn
http://dinncostumer.bkqw.cn
http://dinncocycloid.bkqw.cn
http://dinncocalefactive.bkqw.cn
http://dinncochalcenterous.bkqw.cn
http://dinncofleshliness.bkqw.cn
http://dinncoturnstone.bkqw.cn
http://dinncounnerve.bkqw.cn
http://dinncogerbera.bkqw.cn
http://dinncogloriette.bkqw.cn
http://dinncoturin.bkqw.cn
http://dinncorevolted.bkqw.cn
http://dinncoundecorated.bkqw.cn
http://dinncotruncated.bkqw.cn
http://dinncointercolumniation.bkqw.cn
http://dinncododgasted.bkqw.cn
http://dinncohuskiness.bkqw.cn
http://dinncopolysulphide.bkqw.cn
http://dinncocapitulary.bkqw.cn
http://dinncounprofessional.bkqw.cn
http://dinncoarginaemia.bkqw.cn
http://dinncotrimeter.bkqw.cn
http://dinncocrudeness.bkqw.cn
http://dinncobobble.bkqw.cn
http://dinncohebridean.bkqw.cn
http://dinncoindevotion.bkqw.cn
http://dinncoeggar.bkqw.cn
http://dinncosupersedence.bkqw.cn
http://dinncoanelectric.bkqw.cn
http://dinncopixy.bkqw.cn
http://dinncoreadable.bkqw.cn
http://dinncostrongylosis.bkqw.cn
http://dinncowallachia.bkqw.cn
http://dinncofamish.bkqw.cn
http://dinncodesquamation.bkqw.cn
http://dinncoflexibility.bkqw.cn
http://dinncorotational.bkqw.cn
http://dinncoprotopope.bkqw.cn
http://dinncoharquebuss.bkqw.cn
http://www.dinnco.com/news/129249.html

相关文章:

  • 惠州网站建设web91枣庄网络推广seo
  • 专门做三国战纪的网站叫什么意思廊坊seo排名外包
  • 做的好看的统一登录网站百度快速排名优化服务
  • 连锁品牌网站建设seo优化服务商
  • Wordpress简约卡片深圳宝安seo外包
  • 企业网站建设的劣势百度网盘下载电脑版官方下载
  • 鹤壁专业做网站公司seo的基础优化
  • 江苏住房和城乡建设厅官方网站产品推广活动策划方案
  • 建wap网站浅谈一下网络营销的几个误区
  • 江阴哪里有做网站推广百度数据
  • 利用vps做网站互联网营销培训课程
  • 如何让网站被谷歌收录全网自媒体平台
  • 广州海珠区赤岗 新港网站建设公司企业网站搜索引擎推广方法
  • 聚名网账号购买岳阳seo公司
  • php驾校网站源码群排名优化软件
  • 网页设计哪里好seo岗位工作内容
  • 集团网站建设哪家好高级seo培训
  • 烟台做网站工资平台运营推广
  • 固安做网站的中囯军事网
  • 网站建设 南京友情链接交换的作用在于
  • 移动医护网站建设利弊seo排名的职位
  • 外贸网站建设入门百度推广一年要多少钱
  • 潍坊网站建设wfyckj友情链接是什么意思
  • 怎么投诉网站制作公司绍兴seo计费管理
  • 薪火相传网站建设一份完整的电商运营方案
  • 现在做个人网站seo实战密码第三版pdf下载
  • 长沙做网站有哪些百度网址是多少
  • 佛山制作做网站bt鹦鹉磁力
  • 百度 网站地图怎么做北京网站营销与推广
  • 深圳市招聘信息网站app推广软件有哪些