题目大概:
阿福只能偷不相邻的两个商店的钱,共有n个商店,问阿福最多能偷多少钱。
思路:
dp[n]表示前n个商店最多偷的钱数。a[n]表示每个商店的钱数。
1。。。当前商店如果被偷,则dp[n]=dp[n-2]+a[n].
2。。。不被偷,则dp[n]=dp[n-1]。
感想:
一个递推题。
代码:
题目大概:
阿福只能偷不相邻的两个商店的钱,共有n个商店,问阿福最多能偷多少钱。
思路:
dp[n]表示前n个商店最多偷的钱数。a[n]表示每个商店的钱数。
1。。。当前商店如果被偷,则dp[n]=dp[n-2]+a[n].
2。。。不被偷,则dp[n]=dp[n-1]。
感想:
一个递推题。
代码:
上一篇:动态规划--滑雪
下一篇:动态规划--鸣人的影分身
SpringBoot 动态加载 jar 包,动态配置方案
一、动态规划特点、1、求解类型、2、方向性、3、动态规划状态选择、4、动态规划方程设计、
一、动态规划场景、二、动态规划分类、1、坐标型动态规划、2、前缀划分型动态规
一、问题背景最近在做Datax从阿里云rds数据库到Hive数据同步任务时,发现同步耗时很久,500万的数据同步配置了splitPk并配置了50个线程并发需要212s,任务同步的平均速率一直保持在3-4M/s,而本地的Mysql测试数据库同步时不分片的平均速率就能到20M/s。二. 集群环境Rds环境:8000iops; 8core; 16g内存分片字段类型:bigint类
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M