Lightoj 1004 DP
来源:互联网 发布:金融类的工作知乎 编辑:程序博客网 时间:2024/05/17 07:18
背包
AC代码如下:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(){int T, Case = 1, N;int number[210][210];int dp[210][210];cin >> T;while( T-- ){cin >> N;memset( number, 0, sizeof( number ) );memset( dp, 0, sizeof( dp ) );for( int i = 1; i <= N; i++ ){for( int j = 1; j <= i; j++ ){cin >> number[i][j];}}for( int i = N + 1; i <= 2 * N - 1; i++ ){for( int j = 1; j <= 2 * N - i; j++ ){cin >> number[i][j];}}for( int i = 1; i <= N; i++ ){for( int j = 1; j <= N; j++ ){dp[i][j] = max( dp[i-1][j] + number[i][j], dp[i-1][j-1] + number[i][j] );}}for( int i = N + 1; i <= 2 * N - 1; i++ ){for( int j = 1; j <= N; j++ ){dp[i][j] = max( dp[i-1][j] + number[i][j], dp[i-1][j+1] + number[i][j] );}}cout << "Case " << Case++ << ": " << dp[2*N-1][1] << endl;}return 0;}
- Lightoj 1004 DP
- LightOJ 1004 - Monkey Banana Problem 【DP】
- LightOJ 1004 - Monkey Banana Problem (dp)
- LightOJ - 1004 Monkey Banana Problem(DP)
- LightOJ 1004 - Monkey Banana Problem(dp)
- lightoj 1004 - Monkey Banana Problem 【dp】
- LightOJ-1004-Monkey Banana Problem [DP]
- lightoj 1140 数位DP
- lightoj 1032 数位DP
- lightoj 1068 数位DP
- lightoj 1205 数位DP
- lightoj 1422 区间DP
- Lightoj 1013 DP
- Lightoj 1017 DP
- Lightoj 1018 DP
- Lightoj 1021 数位DP
- Lightoj 1025 DP
- Lightoj 1031 区间DP
- 简单几步教你实现虚拟机-pc机文件共享!
- 参数“Disconnect Application Module Upon Release”的实验报告
- win8安全(I)
- 【OpenCV】imread读取数据为空
- REPRA初探
- Lightoj 1004 DP
- C/C++常见的编程题
- http请求开源框架: AsyncHttpClient
- 权限管理
- 10月15日面试之某视科技
- 基极分压射击偏置的共射放大电路
- Treap LA5031
- C、C++编程入口,常见的编程题
- android下多线程断点续传下载