当前位置:网站首页>数字三角形模型 AcWing 1015. 摘花生
数字三角形模型 AcWing 1015. 摘花生
2022-07-06 05:58:00 【T_Y_F666】
数字三角形模型 AcWing 1015. 摘花生
原题链接
算法标签
DP 线性DP
思路

代码
#include<bits/stdc++.h>
#define int long long
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
const int N = 105;
int f[N][N], a[N][N];
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=read();
while(t--){
int r=read(), c=read();
rep(i, 1, r+1){
rep(j, 1, c+1){
a[i][j]=read();
}
}
rep(i, 1, r+1){
rep(j, 1, c+1){
f[i][j]=max(f[i-1][j], f[i][j-1])+a[i][j];
}
}
printf("%lld\n", f[r][c]);
}
return 0;
}
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
边栏推荐
- Embedded interview questions (IV. common algorithms)
- Cognitive introspection
- Luogu p1460 [usaco2.1] healthy Holstein cows
- IDEA 新UI使用
- Commodity price visualization
- nodejs实现微博第三方登录
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Station B Liu Erden - linear regression and gradient descent
- Luogu [Beginner Level 4] array p1427 number game of small fish
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
猜你喜欢

The difference and usage between continue and break

LTE CSFB process

Seven imperceptible truths in software testing

c语言——冒泡排序

P2802 go home

H3C V7版本交换机配置IRF

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Clear floating mode

C language bubble sort

nodejs实现微博第三方登录
随机推荐
Station B Liu Erden - linear regression and gradient descent
[paper reading] nflowjs: synthetic negative data intensive anomaly detection based on robust learning
Software test interview questions - Test Type
AUTOSAR从入门到精通番外篇(十)-嵌入式S19文件解析
J'ai un chaton.
初识数据库
进程和线程
LAN communication process in the same network segment
Pay attention to the details of pytoch code, and it is easy to make mistakes
[ram IP] introduction and experiment of ram IP core
查询生产订单中某个(些)工作中心对应的标准文本码
Winter 2021 pat class B problem solution (C language)
The usage and difference between strlen and sizeof
实践分享:如何安全快速地从 Centos迁移到openEuler
CoDeSys note 2: set coil and reset coil
Station B, Master Liu Er - back propagation
Title 1093: character reverse order
wib3.0 跨越,在跨越(ง •̀_•́)ง
c语言——冒泡排序
假设检验学习笔记