关键词:
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1176
题意不解释了
简单的记忆化搜索可以拿来练练手,注意要从pos = 5 开始搜索
#include <iostream> #include <cstring> #include <algorithm> #include <cstdio> #include <cmath> using namespace std; const int M = 1e5 + 10; int dp[15][M] , t2[M][12]; int dfs(int pos , int count) { if(count == 0) { if(pos == 6) { return 0; } else { return -1; } } if(dp[pos][count] != -1) return dp[pos][count]; int sum = 0; if(pos == 1) { sum += max(dfs(pos + 1 , count - 1) , dfs(pos , count - 1)); } else if(pos == 11) { sum += max(dfs(pos - 1 , count - 1) , dfs(pos , count - 1)); } else { sum += max(max(dfs(pos - 1 , count - 1) , dfs(pos + 1 , count - 1)) , dfs(pos , count - 1)); } if(sum != -1) { sum += t2[count][pos]; dp[pos][count] = sum; } return sum; } int main() { int n; while(scanf("%d" , &n) != EOF) { if(n == 0) break; memset(t2 , 0 , sizeof(t2)); int T = 0; for(int i = 0 ; i < n ; i++) { int x , y; scanf("%d%d" , &x , &y); t2[y][x + 1]++; T = max(T , y); } memset(dp , -1 , sizeof(dp)); int MAX = 0; for(int i = 1 ; i <= 11 ; i++) { MAX = max(MAX , dfs(i , T)); } printf("%d " , MAX); } return 0; }
hdu-1176免费馅饼(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1176ProblemDescription都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米... 查看详情
hdu1176免费馅饼
免费馅饼TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):48893 AcceptedSubmission(s):16908ProblemDescription都说天上不会掉馅 查看详情
hdu1176免费馅饼——dp
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1176 免费馅饼TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):53204 &n 查看详情
hdu-1176免费馅饼
...就是从下往上加,看看最多可以捡到多少个馅饼。题目:免费 查看详情
hdu1176免费馅饼
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1176解题思路:本题是简单的数塔dp。可以参考博客:http://blog.csdn.net/theonegis/article/details/45801201实现代码:#include<iostream>#include<cstdio>#include<cstring&g 查看详情
hdu1176免费馅饼(dp)
免费馅饼TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):37976 AcceptedSubmission(s):12977ProblemDescription都说天上不会掉馅 查看详情
hdu1176免费馅饼:dp
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1176题意: 横坐标范围为[0,10],你在第0秒站在坐标为5的地方。 在接下来的一段时间内,会有n个馅饼落下来,每一个馅饼有一个位置x和时刻t。 每一秒你最多可以移动1格。... 查看详情
hdu1176-免费馅饼(dp_逆推)
免费馅饼TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):26290 AcceptedSubmission(s):8952ProblemDescription都说天上不会掉馅饼 查看详情
hdu1176免费馅饼
中文题面: http://acm.hdu.edu.cn/showproblem.php?pid=1176思路:这是个二维dpdp[t][x]前者表示时间,后者表示坐标那么转移方程就是dp[t][x]=max(dp[t-1][x],dp[t-1][x+1],dp[t-1][x-1])+cnt[t][x];(注意边界)cnt[t][x]表示t时刻x位置掉的馅饼个数 1#includ 查看详情
[hdu1176]免费馅饼(dp)(代码片段)
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1176题解DP。因为起点固定,终点随意,所以从终点到起点的顺序dp。代码importjava.util.Scanner;publicclassFreePiestaticfinalintMAXT=100005;staticfinalintMAXLEN=10;publicstaticvoidmain(Str 查看详情
hdu-1176免费馅饼(代码片段)
题目:都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以ga... 查看详情
hdu1176免费馅饼(简单dp)
都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马... 查看详情
hdu-1176-免费馅饼(dp)(代码片段)
ProblemDescription都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了... 查看详情
[kuangbin带你飞]专题1-23免费馅饼hdu-1176(代码片段)
题目链接:https://vjudge.net/problem/HDU-1176都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在... 查看详情
杭电1176免费馅饼
http://acm.hdu.edu.cn/showproblem.php?pid=1176免费馅饼TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):25157 Accepte 查看详情
杭电1176免费馅饼
http://acm.hdu.edu.cn/showproblem.php?pid=1176免费馅饼TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):25157 Accepte 查看详情
hdoj1176免费馅饼动态规划
免费馅饼TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):26110 AcceptedSubmission(s):8905ProblemDescription都说天上不会掉馅饼 查看详情
免费馅饼(代码片段)
免费馅饼http://acm.hdu.edu.cn/showproblem.php?pid=1176TimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):66836 Accepte 查看详情