HDU 2571 命运 DP .
2016-09-26 21:55
295 查看
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2571
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int INF=0x3f3f3f3f; int d[20+5][1000+5],R,C,G[20+5][1000+5]; //额 好明显 只能右下走,所以状态很好转移,无后效性 int DP(int x,int y) { int& ans=d[x][y]; if(ans!=-INF) return ans; if(x==R&&y==C) return ans=G[x][y]; if(x+1<=R) ans=max(ans,DP(x+1,y)); if(y+1<=C) ans=max(ans,DP(x,y+1)); for(int k=2;k*y<=C;k++) ans=max(ans,DP(x,y*k)); ans+=G[x][y]; return ans; } int main() { int T; cin>>T; while(T--) { cin>>R>>C; for(int i=1;i<=R;i++) for(int j=1;j<=C;j++) cin>>G[i][j],d[i][j]=-INF; cout<<DP(1,1)<<endl; } return 0; }
相关文章推荐
- HDU 2571 命运(dp)
- HDU 2571 命运 (dp)
- hdu 2571 dp+dfs 命运
- HDU 2571 命运 DP 动态规划
- [HDU] 2571命运 - 最基本的入门dp
- HDU 2571 命运 (DP)
- HDU dp 2571 命运
- HDU 2571 命运(DP)
- HDU 2571 命运(DP)
- hdu 2571 命运【dp】
- HDU 2571 命运 水DP
- HDU 2571 命运 (dp)
- 【DP|水】HDU-2571 命运
- HDU 2571 命运 (DP)
- HDU 2571 命运 (简单DP)
- 命运 (HDU 2571)解题报告(DP - 边界数据处理!韩菱纱乱入~)
- hdu 2571 命运(水DP)
- hdu 2571 命运 DP
- HDU 2571 命运 (简单DP)
- hdu 2571 命运 搜索好题 很多人用dp做