poj2385 Apple Catching (线性dp)】的更多相关文章

https://vjudge.net/problem/POJ-2385 猛刷简单dp的第一天的第一题. 状态:dp[i][j]表示第i秒移动j次所得的最大苹果数.关键要想到移动j次,根据j的奇偶判断人在哪里. 想了挺久的,最后还是参考了一篇和自己思路最近的代码https://blog.csdn.net/hellohelloc/article/details/52050207 我比他缺少的是特判dp[i][0]的状态,后面的一切都以此为基础的. #include<iostream> #inclu…
题目传送门 Apple Catching Apple Catching Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15444   Accepted: 7582 Description It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 an…
Apple Catching   Description It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 and 2) in his field, each full of apples. Bessie cannot reach the apples when they are on the tree, so sh…
Apple Catching Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13447   Accepted: 6549 Description It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 and 2) in his field, ea…
                                            $Apple~Catching$ Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16248   Accepted: 8009 $Description$ It is a little known fact that cows love apples. Farmer John has two apple trees (which are…
题意:2棵苹果树在T分钟内每分钟随机由某一棵苹果树掉下一个苹果,奶牛站在树#1下等着吃苹果,它最多愿意移动W次,问它最多能吃到几个苹果.思路:不妨按时间来思考,一给定时刻i,转移次数已知为j, 则它只能由两个状态转移而来.即上一时刻同一棵树或上一时刻不同的树    dp[i][j] = max(dp[i-1][j], dp[i-1][j-1]);则这一时刻在转移次数为j的情况下最多能接到的苹果为那两个状态的最大值再加上当前能接受到的苹果.(注意当前能否拿到苹果只与转移次数有关)    if (j…
Description It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 and 2) in his field, each full of apples. Bessie cannot reach the apples when they are on the tree, so she must wait for t…
思路: 简单dp. 实现: #include <iostream> #include <cstdio> #include <cstring> using namespace std; ]; ][][]; int dfs(int now,int cur,int rem) { ) return dp[now][cur][rem]; if(now == t) ; ,cur,rem) + (cur == x[now] - ); ) p = max(p, dfs(now, - c…
题意 : 有两颗苹果树,在 1~T 的时间内会有两颗中的其中一颗落下一颗苹果,一头奶牛想要获取最多的苹果,但是它能够在树间转移的次数为 W 且奶牛一开始是在第一颗树下,请编程算出最多的奶牛获得的苹果数 分析 : 这题是不可能爆搜的,可组合的情况实在太多....... 定义 dp[ i ][ j ] ==> 在第 i 个时间点下已经转移了 j 次的最多苹果数是多少 根据定义和奶牛一开始在一号树这个条件,所以初始化时有两种情况 如果第一个时间点落下苹果的是一号树则初始化 dp[ 1 ][ 0 ] =…
题意:有两棵树,标号为1和2,在Tmin内,每分钟都会有一个苹果从其中一棵树上落下,问最多移动M次的情况下(该人可瞬间移动),最多能吃到多少苹果.假设该人一开始在标号为1的树下. 分析: 1.dp[x][y][z]---第x分钟移动了y次的情况下,现在位于标号为z的树下最多吃到的苹果数. 2.枚举所有的时间.次数和可能位于的树下. 若第i分钟该人位于标号为k的树下,第i + 1分钟苹果从标号为a[i+1]的树上落下. (1)k==a[i], 此人站在标号为k的树下不移动,即可再吃到一个苹果:dp…