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

做网站开发要学什么品牌设计公司简介

做网站开发要学什么,品牌设计公司简介,网站佣金怎么做分录,不需要备案的服务器2014-03-21 22:05 题目#xff1a;给你N个盒子堆成一座塔#xff0c;要求下面盒子的长和宽都要严格大于上面的。问最多能堆多少个盒子#xff1f; 解法1#xff1a;O(n^2)的动态规划解决。其实是最长递增子序列问题#xff0c;所以也可以用O(n * log(n))的优化算法。 代码… 2014-03-21 22:05 题目给你N个盒子堆成一座塔要求下面盒子的长和宽都要严格大于上面的。问最多能堆多少个盒子 解法1O(n^2)的动态规划解决。其实是最长递增子序列问题所以也可以用O(n * log(n))的优化算法。 代码 // 11.7 n boxes are to stack up to a tower. Every box must be strictly smaller in width and height than the one right below it. // How many boxes at most can you stack up? #include algorithm #include cstdio #include vector using namespace std;struct Box {int x;int y;Box(int _x 0, int _y 0): x(_x), y(_y) {};bool operator (const Box other) {if (x ! other.x) {return x other.x;} else {return y other.y;}}; };int main() {vectorBox v;vectorint dp;int n;int i, j;int res;while (scanf(%d, n) 1 n 0) {v.resize(n);for (i 0; i n; i) {scanf(%d%d, v[i].x, v[i].y);}sort(v.begin(), v.end());dp.resize(n);res 0;for (i 0; i n; i) {dp[i] 1;for (j 0; j i; j) {if (v[j].x v[i].x v[j].y v[i].y) {dp[i] dp[j] 1 dp[i] ? dp[j] 1 : dp[i];}}res dp[i] res ? dp[i] : res;}printf(%d\n, res);v.clear();dp.clear();}return 0; } 解法2用二分查找优化后的代码其中使用了STL算法库提供的lower_bound()二分也不总是要手写的。 代码 1 // 11.7 n boxes are to stack up to a tower. Every box must be strictly smaller in width and height than the one right below it.2 // How many boxes at most can you stack up?3 #include algorithm4 #include cstdio5 #include vector6 using namespace std;7 8 struct Box {9 int x; 10 int y; 11 Box(int _x 0, int _y 0): x(_x), y(_y) {}; 12 13 bool operator (const Box other) { 14 if (x ! other.x) { 15 return x other.x; 16 } else { 17 return y other.y; 18 } 19 }; 20 }; 21 22 int main() 23 { 24 vectorBox v; 25 vectorint dp; 26 vectorint::iterator it; 27 int n; 28 int i; 29 30 while (scanf(%d, n) 1 n 0) { 31 v.resize(n); 32 for (i 0; i n; i) { 33 scanf(%d%d, v[i].x, v[i].y); 34 } 35 sort(v.begin(), v.end()); 36 dp.push_back(v[0].y); 37 for (i 1; i n; i) { 38 if (v[i].y dp[dp.size() - 1]) { 39 dp.push_back(v[i].y); 40 } else { 41 it lower_bound(dp.begin(), dp.end(), v[i].y); 42 *it v[i].y; 43 } 44 } 45 printf(%d\n, (int)dp.size()); 46 47 v.clear(); 48 dp.clear(); 49 } 50 51 return 0; 52 }   转载于:https://www.cnblogs.com/zhuli19901106/p/3616836.html
http://www.huolong8.cn/news/332157/

相关文章:

  • 网站开发drupal企业门户网站的主要论点及写作体会怎么写
  • 天津建网站的公司wordpress分类模板
  • 网站域名申请了该怎么做关于网站建设的建议的征集
  • 达州市住房与城乡建设厅网站做网站所具备的的条件
  • 网站建设相关法律代运营
  • 企业网站建设的背景wordpress怎么进入编辑模式
  • 做学术用的网站国内国际时事100字
  • 建五金方面的网站张槎网站设计
  • 做淘宝客网站用什么系统千图app的优势
  • 怎么做展示型网站网站建设 网站推广
  • 投资网站排行oppo开放平台
  • 做网站先用dw还是asp网站开发需要哪些知识和工具
  • 做网站需要切图吗成都网站建设028net
  • 中国石家庄网站wordpress照片评选插件
  • 张家港网站建设模板vps上的网站运行太慢
  • 深圳网站建设营销策划wordpress萌化
  • 群站wordpress蕲春县住房和城乡建设局网站
  • 不锈钢网站哪家最专业网站建设中的端口
  • 仿站小工具 wordpress成都好玩的地方
  • 备案的网站程序上传网站域名去哪买
  • 微信制作微网站开发企业建设好一个网站后 如何进行网站推广
  • 怎么查询网站的点击量小型网站搭建
  • 网站建设视频百度网盘杭州百度推广代理商
  • 建设银行网站电脑版企业整套vi设计都包含哪些
  • 柳州网站建设多少钱网站建设新发展
  • 广东企业黄页网站中企动力优秀网站
  • 如何做图片 网站 链接怎样上传网站到百度
  • 网站建设的专业术语wordpress 全站404
  • 网站主页设计教程北京网站建设百度排名
  • 出售企业网站备案资料揭阳网站制作价格