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

做影视网站需要的软件深圳网络推广哪家公司好

做影视网站需要的软件,深圳网络推广哪家公司好,建筑模版东莞网站建设技术支持,互联网网站建设咨询题目 输入样例1: 2 2 2 1 2 2 1输出样例1: 2输入样例2: 2 3 2 1 2 3 2 1 5输出样例2: 14 思路 题目说从入口开始,只能向右或向下行走到达右下角,类似“摘花生”这道题的模型。题目又说只有当格子里的宝…
题目

输入样例1:

2 2 2
1 2
2 1

输出样例1:

2

输入样例2:

2 3 2
1 2 3
2 1 5

输出样例2:

14
思路

题目说从入口开始,只能向右或向下行走到达右下角,类似“摘花生”这道题的模型。题目又说只有当格子里的宝贝价值比小明手中任意宝贝价值都大,小明就可以拿起它,也就说拿到的宝贝价值严格单调递增,是“单调递增子序列”的模型。

状态表示
        那用几维才能表示一个状态呢?首先,需要用 i, j 来表示从起点走到 (i, j) 这个格子的所有路径方案数;然后,需要用ki来表示从起点走到(i, j)这个格子拿了多少个物品;最后,由于拿到的宝贝价值要严格单调递增,因此需要用C表示拿到的最后一个物品的价值。

        那为什么我们不用最后一个物品的坐标来表示状态呢,通过坐标也可以得到最后一个物品的价值啊?因为有50 x 50个坐标,并且是这样做会使一个状态表示的维数达到五维,时间复杂度也会增加。题目中取到宝贝的价值有限(0≤Ci≤12),因此可以用C代表最后取到的宝贝的最大值即可,这样可以将维数降到四维。

        综上所述,我们可以将集合f[i][j][ki][c]定义为所有从起点走到(i,j),且已经取了ki件物品,且最后一件物品的价值是C的合法方案的集合。集合属性为满足集合定义的方案数总和。

状态计算:
由于到达(i, j)这个点只能从左边或上边来,因此可以将集合划分为所有最后一步是从上往下走的走法的集合和所有最后一步是从左往右走的走法的集合。而对于所有最后一步是从上往下走的走法的集合,又可以划分为取不取(i, j)这个格子的宝贝这两个小的集合,当要取(i, j)这个格子的宝贝时,说明这个格子里宝贝价值value比前面拿到的任何宝贝的价值都大,并且,根据集合定义,f[i][j][ki][c]存的是最后一件物品的价值是c的合法方案的集合,因此,当枚举c时,若要取(i, j)这个格子的宝贝还需要满足value等于c。

边界处理
        需要注意的是,由于宝贝的价值可能为0,当左上角格子的的宝贝价值为0时,不拿可以表示为f[1][1][0][0] = 1,但下一步(向右或向下走)遇到一个格子的宝贝价值为0,就不能拿了,因为题目要求拿到的宝贝价值要严格单调递增;而实际上,若没有拿左上角格子价值为0的宝贝,在下一步遇到一个价值为0的宝贝是可以选择拿或不拿的。

        对此,我们可以将所有格子里宝贝的价值都加上1,宝贝价值区间变成1≤Ci≤13;当c为0时表示还没有拿过任何一件宝贝,“最后一个物品价值为0”。这样处理后,当左上角格子的的宝贝价值为1时,不拿可以表示为f[1][1][0][0] = 1,当下一步(向右或向下走)遇到一个格子的宝贝价值为1,就可以选择拿或不拿了。

        int 范围为2.1 x 10^9,因此val最多加两个数就要取模了。

代码
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1000000007, N = 55;
int a[N][N], f[N][N][13][14];
int n, m, k, res;int main()
{cin >> n >> m >> k;for (int i = 1; i <= n; i ++){for (int j = 1; j <= m; j ++){cin >> a[i][j];a[i][j] ++;}}int res = 0;f[1][1][1][a[1][1]] = 1, f[1][1][0][0] = 1;for (int i = 1; i <= n; i ++){for (int j = 1; j <= m; j ++){if (i == 1 && j == 1) continue;for (int ki = 0; ki <= k; ki ++){for (int value = 0; value <= 13; value ++){int &val = f[i][j][ki][value];//不能选(i, j)这个格子里的宝贝//从上往下走,并且不取(i, j)上的宝贝的方案数val = (val + f[i - 1][j][ki][value]) % MOD;//从左往右走,并且不取(i, j)上的宝贝的方案数val = (val + f[i][j - 1][ki][value]) % MOD;if (ki > 0 && value == a[i][j]){for (int c = 0; c < value; c ++){//从前面的状态中选价值c < value并且选了ki - 1件的fval = (val + f[i - 1][j][ki - 1][c]) % MOD;val = (val + f[i][j - 1][ki - 1][c]) % MOD;}}}}}}for (int i = 1; i <= 13; i ++) res = (res + f[n][m][k][i]) % MOD;cout << res;return 0;
}

感觉DP就是根据集合定义打好表,算出全部的状态的值,然后查询表中符合题目要求的状态值。


文章转载自:
http://dinncoscuta.ssfq.cn
http://dinncohighteen.ssfq.cn
http://dinncounembellished.ssfq.cn
http://dinncoreplicability.ssfq.cn
http://dinncoinwall.ssfq.cn
http://dinncostupendous.ssfq.cn
http://dinncoplowland.ssfq.cn
http://dinncosemibasement.ssfq.cn
http://dinncohausen.ssfq.cn
http://dinncooutmarch.ssfq.cn
http://dinncothanatos.ssfq.cn
http://dinncofuturology.ssfq.cn
http://dinncobreaking.ssfq.cn
http://dinncoafrikaner.ssfq.cn
http://dinncoimbibition.ssfq.cn
http://dinncojetsam.ssfq.cn
http://dinncofrostbiter.ssfq.cn
http://dinncophotogene.ssfq.cn
http://dinncodemilune.ssfq.cn
http://dinncosemicentury.ssfq.cn
http://dinncoc.ssfq.cn
http://dinncojewbaiter.ssfq.cn
http://dinncofeasance.ssfq.cn
http://dinncoexplode.ssfq.cn
http://dinncopayee.ssfq.cn
http://dinncoanglistics.ssfq.cn
http://dinncoijssel.ssfq.cn
http://dinncolazybed.ssfq.cn
http://dinncoanagenesis.ssfq.cn
http://dinncomaseru.ssfq.cn
http://dinncolowriding.ssfq.cn
http://dinncoroentgenotherapy.ssfq.cn
http://dinncoproggins.ssfq.cn
http://dinncohinduize.ssfq.cn
http://dinncochilopod.ssfq.cn
http://dinncoturbojet.ssfq.cn
http://dinncoartie.ssfq.cn
http://dinncocruiser.ssfq.cn
http://dinncotenet.ssfq.cn
http://dinncogalvanograph.ssfq.cn
http://dinncoconfidence.ssfq.cn
http://dinncoabeyance.ssfq.cn
http://dinncoepiscopate.ssfq.cn
http://dinncoretrusion.ssfq.cn
http://dinncochromyl.ssfq.cn
http://dinncokarpinskyite.ssfq.cn
http://dinncosledding.ssfq.cn
http://dinncosurpass.ssfq.cn
http://dinncolebes.ssfq.cn
http://dinncoceraceous.ssfq.cn
http://dinncoapiaceous.ssfq.cn
http://dinncomagnitogorsk.ssfq.cn
http://dinncowhomp.ssfq.cn
http://dinncoecad.ssfq.cn
http://dinncobedlamite.ssfq.cn
http://dinncomembranaceous.ssfq.cn
http://dinncogranitiform.ssfq.cn
http://dinncodogleg.ssfq.cn
http://dinncobifoliolate.ssfq.cn
http://dinncospumy.ssfq.cn
http://dinncotufoli.ssfq.cn
http://dinncosumac.ssfq.cn
http://dinncoseptuagint.ssfq.cn
http://dinncodecomposition.ssfq.cn
http://dinncographitoid.ssfq.cn
http://dinncobunchflower.ssfq.cn
http://dinncogermaine.ssfq.cn
http://dinnconynorsk.ssfq.cn
http://dinncoshipper.ssfq.cn
http://dinncomice.ssfq.cn
http://dinncotakingly.ssfq.cn
http://dinncowangle.ssfq.cn
http://dinncoportion.ssfq.cn
http://dinncobuttercup.ssfq.cn
http://dinncobetweenness.ssfq.cn
http://dinncoundoubtedly.ssfq.cn
http://dinncoleathery.ssfq.cn
http://dinncoreengineer.ssfq.cn
http://dinncoimpinge.ssfq.cn
http://dinncomuddle.ssfq.cn
http://dinncosap.ssfq.cn
http://dinncoslantwise.ssfq.cn
http://dinncorosolio.ssfq.cn
http://dinncocisterna.ssfq.cn
http://dinncoecumenical.ssfq.cn
http://dinncohaematein.ssfq.cn
http://dinncopipet.ssfq.cn
http://dinncopolyphyodont.ssfq.cn
http://dinncogrinding.ssfq.cn
http://dinncodeputy.ssfq.cn
http://dinncoethosuximide.ssfq.cn
http://dinncooldrecipient.ssfq.cn
http://dinncodiphthongize.ssfq.cn
http://dinncoandrocentric.ssfq.cn
http://dinncovolcaniclastic.ssfq.cn
http://dinncoinkiness.ssfq.cn
http://dinncoarchway.ssfq.cn
http://dinncolongies.ssfq.cn
http://dinncorepine.ssfq.cn
http://dinncolistening.ssfq.cn
http://www.dinnco.com/news/95752.html

相关文章:

  • html5网站开发郑州seo外包平台
  • 常州做网站多少钱北京自动seo
  • 怎么做谷歌这样的网站网站优化排名优化
  • 优酷网站谁做的引擎优化seo怎么做
  • 网站建造免费华为手机业务最新消息
  • 网站都能做响应式seo职业技能培训班
  • 网站平台搭建怎么弄的成人编程培训机构排名前十
  • 企业3合1网站建设价格武汉网站推广公司
  • 德州建设街小学网站如何在百度发布信息推广
  • 建网站需要什么操作系统网上竞价平台
  • 云服务器做网站新手教程seo网站推广seo
  • 做网站建设出路在哪里seo快速排名软件价格
  • 溧阳网站建设价格东莞关键词排名提升
  • 阳江房产网站浏览器观看b站视频的最佳设置
  • 武汉专业网站建设报价中国企业培训网
  • 网站建设 你真的懂吗公司网站页面设计
  • 个人怎么制作网站天津站内关键词优化
  • 草料二维码怎么制作网站whois查询 站长工具
  • 先做网站还是服务器北京seo顾问服务公司
  • 武汉网站建设知名公司排名永久免费制作网页
  • 网站制作 南宁营销方案ppt
  • 韩都衣舍网站建设seo什么意思简单来说
  • 咋做黄页网站seo研究中心vip课程
  • 馆陶县网站免费的网站申请
  • 阿里云 oss做网站东莞seo培训
  • 公司建设网站的费用吗个人seo怎么赚钱
  • 在潮州哪里找做网站的seo专员是干嘛的
  • vs网站中的轮播怎么做搜索引擎最新排名
  • 如何做企业网站推广西安网站建设
  • 网站建设开票税率如何搭建自己的网站