当前位置:网站首页>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;
}边栏推荐
- Complex network modeling (III)
- Lattice coloring - matrix fast power optimized shape pressure DP
- Leetcode 187 Repeated DNA sequence (2022.07.06)
- Interactive book delivery - signed version of Oracle DBA work notes
- ZCMU--1492: Problem D(C语言)
- Bayes' law
- 拓维信息使用 Rainbond 的云原生落地实践
- 漏洞复现-Fastjson 反序列化
- Explore dry goods! Apifox construction ideas
- JSON data flattening pd json_ normalize
猜你喜欢

【数字IC验证快速入门】10、Verilog RTL设计必会的FIFO

数据库实时同步利器——CDC(变化数据捕获技术)

Myabtis_ Plus

Jmeter 的使用

Application of slip ring of shipborne radar antenna

Network learning (III) -- highly concurrent socket programming (epoll)

调用 pytorch API完成线性回归

JS cross browser parsing XML application

【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门

These five fishing artifacts are too hot! Programmer: I know, delete it quickly!
随机推荐
offer收割机:两个长字符串数字相加求和(经典面试算法题)
Relevant data of current limiting
Es FAQ summary
Leetcode simple question: find the K beauty value of a number
Complex network modeling (I)
C language queue
Excel import function of jeesite form page
JS cross browser parsing XML application
青龙面板-今日头条
The zblog plug-in supports the plug-in pushed by Baidu Sogou 360
调用 pytorch API完成线性回归
央视太暖心了,手把手教你写HR最喜欢的简历
Content of string
海信电视开启开发者模式
jeeSite 表单页面的Excel 导入功能
ZCMU--1396: 队列问题(2)
积分商城管理系统中应包含的四大项
Who has docker to install MySQL locally?
基于Pytorch 框架手动完成线性回归
【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)