当前位置:网站首页>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;
}
边栏推荐
- 【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
- 复杂网络建模(一)
- [quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)
- 太真实了,原来自己一直没有富裕起来是有原因的
- 王爽 《汇编语言》之寄存器
- Introduction à l'objet blob
- Interactive book delivery - signed version of Oracle DBA work notes
- Qinglong panel -- Huahua reading
- Call pytorch API to complete linear regression
- 【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
猜你喜欢
Application of slip ring of shipborne radar antenna
Linux server development, MySQL index principle and optimization
王爽 《汇编语言》之寄存器
OpenVSCode云端IDE加入Rainbond一体化开发体系
船载雷达天线滑环的使用
Excel import function of jeesite form page
Rainbond结合NeuVector实践容器安全管理
2022 Inner Mongolia latest advanced fire facility operator simulation examination question bank and answers
Who has docker to install MySQL locally?
数据库实时同步利器——CDC(变化数据捕获技术)
随机推荐
The charm of SQL optimization! From 30248s to 0.001s
Bugku CTF daily one question chessboard with only black chess
Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
The simple problem of leetcode is to judge whether the number count of a number is equal to the value of the number
运放电路的反馈电阻上并联一个电容是什么作用
Recursive method to verify whether a tree is a binary search tree (BST)
船载雷达天线滑环的使用
漏洞复现-Fastjson 反序列化
拓维信息使用 Rainbond 的云原生落地实践
【數字IC驗證快速入門】15、SystemVerilog學習之基本語法2(操作符、類型轉換、循環、Task/Function...內含實踐練習)
Es FAQ summary
漏洞複現-Fastjson 反序列化
Make LIVELINK's initial pose consistent with that of the mobile capture actor
Unityhub cracking & unity cracking
Introduction à l'objet blob
青龙面板--花花阅读
Thinkcmf6.0 installation tutorial
Recursive method constructs binary tree from middle order and post order traversal sequence
Yugu p1020 missile interception (binary search)
Complex network modeling (I)