当前位置:网站首页>Zcmu--1492: problem d (C language)
Zcmu--1492: problem d (C language)
2022-07-07 08:11:00 【Little why】
Description
Chieh Recently I saw Lan Xiang very hot on the Internet . Somehow he thought of a problem , There is one n*m Matrix
There are k A stone .. Now the excavator is in the upper left corner , Excavators are very powerful .. You can put unlimited stones
But it can only move to the right or down , Now? Chieh Want to know the most stones from the upper left corner to the lower right corner .
Input
T Group number T<=100
n m 1<=n. m<=1000
n That's ok m Number Is the number of stones 0<=s<=1000
Output
For each group of test data , Output the corresponding answer .
Sample Input
Sample Output
#include <stdio.h>
#include <string.h>
int f[1005][1005]={0};
int max(int a,int b){ //max function
if(a>=b) return a;
return b;
}
int main()
{
int t,i,n,m,j;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
scanf("%d",&f[i][j]);
f[i][j]=f[i][j]+max(f[i][j-1],f[i-1][j]);// Select the largest one on the left and above
}
}
printf("%d\n",f[n][m]);
memset(f,0,sizeof(f)); // Remember to initialize 0, Otherwise there will be residues , Cause errors in the next set of data
}
return 0;
}
边栏推荐
- The element with setfieldsvalue set is obtained as undefined with GetFieldValue
- 力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
- Register of assembly language by Wang Shuang
- Roulette chart 2 - writing of roulette chart code
- QT learning 26 integrated example of layout management
- Jmeter 的使用
- ZCMU--1492: Problem D(C语言)
- LeetCode中等题之我的日程安排表 I
- Merging binary trees by recursion
- 复杂网络建模(一)
猜你喜欢
调用 pytorch API完成线性回归
Réplication de vulnérabilité - désrialisation fastjson
Who has docker to install MySQL locally?
[step on the pit series] H5 cross domain problem of uniapp
Force buckle 144 Preorder traversal of binary tree
The largest 3 same digits in the string of leetcode simple question
Dedecms collects content without writing rules
青龙面板-今日头条
Rainbond 5.7.1 支持对接多家公有云和集群异常报警
2022 Inner Mongolia latest advanced fire facility operator simulation examination question bank and answers
随机推荐
使用 Nocalhost 开发 Rainbond 上的微服务应用
Basic use of CTF web shrink template injection nmap
[untitled]
在Rainbond中一键部署高可用 EMQX 集群
Application of slip ring of shipborne radar antenna
The charm of SQL optimization! From 30248s to 0.001s
Recursive method to verify whether a tree is a binary search tree (BST)
Blob 对象介绍
LeetCode简单题之判断一个数的数字计数是否等于数位的值
eBPF Cilium实战(2) - 底层网络可观测性
Interactive book delivery - signed version of Oracle DBA work notes
漏洞複現-Fastjson 反序列化
2022 Inner Mongolia latest advanced fire facility operator simulation examination question bank and answers
Chip design data download
Linux server development, redis protocol and asynchronous mode
DNS server configuration
Linux server development, MySQL cache strategy
Réplication de vulnérabilité - désrialisation fastjson
LeetCode中等题之我的日程安排表 I
JS cross browser parsing XML application