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

惠东网站设计动画设计基础

惠东网站设计,动画设计基础,石家庄网站建设今天改网名,wordpress 亚马逊存储目录 循环枚举 P2241 统计方形#xff08;数据加强版#xff09; P2089 烤鸡 P1618 三连击#xff08;升级版#xff09; 子集枚举 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)为每次发生长变化或者宽变化的矩形总个数又因为长方形与正方形唯一区别是长宽是否相等因此代码如下 #includeiostream 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接口下面附上代码注意输入123456789输出123456789 #includebits/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开始 原因123456789满足{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 普及组] 选数 这是一道简单的模拟题枚举出所有可能情况不会超过规定时间的以下附上k3的代码如果需要更大的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;vectorint 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;vectorstring 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的使用以下为代码 #includebits/stdc.h using namespace std;int main() {int n, m; cin n m;vectorint 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://www.w-s-a.com/news/450265/

相关文章:

  • 郑州模板网站建设策划公司做网站怎么赚钱滑县电
  • 东昌府聊城网站优化秦皇岛市妇幼保健院
  • 做网站能赚钱吗网页升级访问通知天天更新
  • 做网站使用什么软件的免费招聘网
  • 宁波网站建设公司推荐哪家淄博网站制作公司服务
  • 做网站网页挣钱不免费主题wordpress
  • 如何提高你的网站的粘性手机网站整站模板下载
  • 学校网站建设制度网站相关推荐怎么做
  • 昌图网站wordpress 视频外链
  • 企业网站要怎么建设重庆住房城乡建设部网站
  • html5网站特点seo教程培训班
  • 深圳网站建设哪个最好网站 多语
  • 互联网工具型网站创意网络广告
  • 影视公司网站建设网页界面设计分辨率是多少dpi
  • 免费的做微博的网站模板wordpress 页面 首页
  • 摄影图片网站网站辅导运营与托管公司
  • 做课件的网站长春免费建站模板
  • 响应式网站模板下载免费wordpress 小工具移动
  • 网站标签title在线app制作平台
  • 做电器推广的网站简洁大方的网站模板
  • 网站开发的平台100个详情页设计图
  • wordpress淘宝客建站教程视频知名的设计公司网站
  • 批量做单页网站怎么直接用代码做网站
  • 百度收录较好的网站办公室装修设计方案
  • 建设购物网站要求cnzz数据统计
  • 深圳自适应网站建设价格广东网站建设软件
  • 网页设计介绍北京网站自己做彩票网站
  • 最牛论坛网站app生成链接
  • 用jsp做的网站源代码网站优化说明
  • 网站建设公司名字甘肃省和住房建设厅网站