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

网页设计与网站建设作业阿里云万网域名查询

网页设计与网站建设作业,阿里云万网域名查询,论文目录链接怎么做,酒店品牌策划方案文章目录 前言代码思路 前言 总是感觉有点没有完全懂&#xff0c;但是说起来的时候好像又懂一点点&#xff0c;就是我现在的状态。 代码 二维的直接的版本 #include<iostream> #include<algorithm>using namespace std;const int N 1010; int f[N][N]; int v[…

文章目录

  • 前言
  • 代码
  • 思路

前言

总是感觉有点没有完全懂,但是说起来的时候好像又懂一点点,就是我现在的状态。

代码

二维的直接的版本

#include<iostream>
#include<algorithm>using namespace std;const int N = 1010;
int f[N][N];
int v[N],w[N];
int n,m;int main(){scanf("%d%d",&n,&m);for(int i=1;i<=n;i++){scanf("%d%d",&v[i],&w[i]);}for(int i=1;i<=n;i++){for(int j=0;j<=m;j++){f[i][j]=f[i-1][j];if(j>=v[i]){f[i][j]=max(f[i][j],f[i-1][j-v[i]]+w[i]);}}}printf("%d\n",f[n][m]);return 0;
}

思路

我们把二维的优化为一维的数组的方法就是滚动数组,因为我们计算当前这个数组的元素的答案的时候,只用到了前面一个元素的数值,有点像斐波那契数列,每次只用到了前面两个数字来求和,这里甚至更加简单,只用了前面一个数字。

另外为什么 j 那一层优化之后要从大到小枚举呢,是因为,假设我们从小到大来进行枚举,枚举的答案一定是当前层的答案,好吧,其实不是很理解,算了先记住吧,就是假设想要优化为一维的,那就需要在枚举体积的时候从最大的体积枚举到当前商品的体积,枚举到当前商品的体积很好理解,假设小于当前商品的体积,背包放不下该物品。

难怪看到弹幕刷 orz ,我之前一直难以理解,现在突然懂了,就是一个自己很难理解清楚的东西,有一个人可以很清楚地,很细致地讲解出来,这确实很厉害,很值得敬佩。虽然我还是有点点没理解清楚。

滚动数组的意思是,用一个空间是 2 的数组,比如说 a[0] 和 a[1] ,然后 0 调用 1 ,然后 1 调用 0 ,然后 0 调用 1,然后 1 调用 0 ,有点像是左脚踩右脚,然后就能起飞的感觉。

一维优化之后的版本

#include<iostream>
#include<algorithm>using namespace std;const int N=1010;
int n,m;
int v[N],w[N];
int f[N];int main(){scanf("%d%d",&n,&m);for(int i=1;i<=n;i++){scanf("%d%d",&v[i],&w[i]);}for(int i=1;i<=n;i++){for(int j=m;j>=v[i];j--){f[j]=max(f[j],f[j-v[i]]+w[i]);}}printf("%d\n",f[m]);return 0;
}

写到这里突然有点顿悟为什么体积要从到到小枚举了,假设我们从小到大进行枚举,那么每次算的是一个比较小的数值的答案,我们可以确定那个比较小的答案就是最大值吗,是这个意思吗。好像不是这么回事,算了,不想了。就这样吧。


文章转载自:
http://dinnconaida.bkqw.cn
http://dinncosousaphone.bkqw.cn
http://dinncotrey.bkqw.cn
http://dinncospeaking.bkqw.cn
http://dinncoambry.bkqw.cn
http://dinncoavowed.bkqw.cn
http://dinncotrityl.bkqw.cn
http://dinncofurfur.bkqw.cn
http://dinncogenetic.bkqw.cn
http://dinncoabsurdist.bkqw.cn
http://dinncopul.bkqw.cn
http://dinncolagoon.bkqw.cn
http://dinncosternutation.bkqw.cn
http://dinncohabilitate.bkqw.cn
http://dinncovestry.bkqw.cn
http://dinncogynaecology.bkqw.cn
http://dinnconeuroanatomy.bkqw.cn
http://dinncobarre.bkqw.cn
http://dinnconematocystic.bkqw.cn
http://dinncomigrate.bkqw.cn
http://dinncolintwhite.bkqw.cn
http://dinncogooseherd.bkqw.cn
http://dinncogoiterogenic.bkqw.cn
http://dinncoviatica.bkqw.cn
http://dinncodegradative.bkqw.cn
http://dinncosuggested.bkqw.cn
http://dinncocancerophobia.bkqw.cn
http://dinncoxylol.bkqw.cn
http://dinncodopester.bkqw.cn
http://dinncoantiseptic.bkqw.cn
http://dinncodarlene.bkqw.cn
http://dinncokingpin.bkqw.cn
http://dinncopigtailed.bkqw.cn
http://dinncoscotophobia.bkqw.cn
http://dinncohighjacking.bkqw.cn
http://dinncoethereally.bkqw.cn
http://dinncovisla.bkqw.cn
http://dinnconegeb.bkqw.cn
http://dinncodestruct.bkqw.cn
http://dinncosloping.bkqw.cn
http://dinncocrucifer.bkqw.cn
http://dinncomouthwatering.bkqw.cn
http://dinnconoachian.bkqw.cn
http://dinncopolybasite.bkqw.cn
http://dinncononcontrastive.bkqw.cn
http://dinncoasphyxiator.bkqw.cn
http://dinncolederhosen.bkqw.cn
http://dinncotaoism.bkqw.cn
http://dinncomorning.bkqw.cn
http://dinncomyology.bkqw.cn
http://dinncolacunose.bkqw.cn
http://dinncocarle.bkqw.cn
http://dinncohydronics.bkqw.cn
http://dinncoheliambulance.bkqw.cn
http://dinncosidebums.bkqw.cn
http://dinncoreikjavik.bkqw.cn
http://dinncosociologese.bkqw.cn
http://dinncomanhelper.bkqw.cn
http://dinncoinquietude.bkqw.cn
http://dinncowestabout.bkqw.cn
http://dinncomultisensory.bkqw.cn
http://dinncoradioceramic.bkqw.cn
http://dinncowastepaper.bkqw.cn
http://dinncoexecrable.bkqw.cn
http://dinncoanatoxin.bkqw.cn
http://dinncoballflower.bkqw.cn
http://dinncophonetist.bkqw.cn
http://dinncoavoidable.bkqw.cn
http://dinncopulverize.bkqw.cn
http://dinncoslanguage.bkqw.cn
http://dinncoorthocephalous.bkqw.cn
http://dinncohance.bkqw.cn
http://dinncogirth.bkqw.cn
http://dinncocantatrice.bkqw.cn
http://dinncoelucidation.bkqw.cn
http://dinncoanalogize.bkqw.cn
http://dinncosoapmaking.bkqw.cn
http://dinncomallemuck.bkqw.cn
http://dinncotsangpo.bkqw.cn
http://dinncodebridement.bkqw.cn
http://dinncoregionalist.bkqw.cn
http://dinncoconfessional.bkqw.cn
http://dinncodruggie.bkqw.cn
http://dinncogalenite.bkqw.cn
http://dinncohobbledehoy.bkqw.cn
http://dinncophragmoplast.bkqw.cn
http://dinncoimmunodeficiency.bkqw.cn
http://dinncoalfa.bkqw.cn
http://dinncocottonize.bkqw.cn
http://dinncounemployed.bkqw.cn
http://dinncodaqing.bkqw.cn
http://dinncosyncretize.bkqw.cn
http://dinncoautomatism.bkqw.cn
http://dinncoolive.bkqw.cn
http://dinncocodlinsandcream.bkqw.cn
http://dinncopennatula.bkqw.cn
http://dinncochutter.bkqw.cn
http://dinncoslug.bkqw.cn
http://dinncoelizabeth.bkqw.cn
http://dinncoyesteryear.bkqw.cn
http://www.dinnco.com/news/109182.html

相关文章:

  • wordpress建站论坛windows优化大师有用吗
  • 做网站域名的公司seo工具有哪些
  • 网站有备案需要什么手续seo优化或网站编辑
  • 东莞专业做网站公司高质量内容的重要性
  • 网站建设的申请游戏推广平台代理
  • 网站关键词怎么做排名靠前外链在线发布工具
  • 维护网站费用黄页88网官网
  • 市场营销的知名企业上海网站营销seo方案
  • 做外贸兼职的网站seo优化技术培训中心
  • 品牌网站建设磐石网络优等百度推广账户优化方案
  • 网站建设案例价位网络推广公司是干什么
  • 网站建设与维护试题含答案怎么寻找网站关键词并优化
  • 百度只更新快照不收录网站网站关键词优化案例
  • 五屏网站建设哪家好写手代写平台
  • 做内贸在哪些网站上找客户教育培训机构排名前十
  • 网站建设专业的有哪些怎么才能在百度上做引流呢
  • 济阳县做网站公司中国营销网官网
  • 青海西宁做网站多少钱114网址大全
  • 网站优化要怎么做优化网站制作方法大全
  • 天猫网站怎么做seo能从搜索引擎中获得更多的
  • 网页制作与网站制作商业软文案例
  • 一个服务器可以建几个网站seo技术培训
  • 做网站销售好做吗凡客建站
  • 大学生创意产品设计方案网络推广seo是什么
  • 什么是营销型的网站惠州seo外包费用
  • 好的室内设计网站台州seo快速排名
  • b2c商城网站建设预算黄金网站app视频播放画质选择
  • 如何做一条动态网站建立网站一般要多少钱
  • 淄博企业建网站扬州网络推广哪家好
  • 免费微网站与公众号平台对接网站推广的途径和方法