当前位置:网站首页>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 simple problem of leetcode is to judge whether the number count of a number is equal to the value of the number
- 藏书馆App基于Rainbond实现云原生DevOps的实践
- [quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)
- 漏洞复现-Fastjson 反序列化
- 调用 pytorch API完成线性回归
- Call pytorch API to complete linear regression
- OpenVSCode云端IDE加入Rainbond一体化开发体系
- QT learning 26 integrated example of layout management
- Find the mode in the binary search tree (use medium order traversal as an ordered array)
- Recursive method to construct binary tree from preorder and inorder traversal sequence
猜你喜欢
Who has docker to install MySQL locally?
CTF-WEB shrine模板注入nmap的基本使用
Linux server development, detailed explanation of redis related commands and their principles
快解析内网穿透助力外贸管理行业应对多种挑战
Niu Mei's mathematical problem --- combinatorial number
JS复制图片到剪切板 读取剪切板
UnityHub破解&Unity破解
藏书馆App基于Rainbond实现云原生DevOps的实践
复杂网络建模(一)
Main window in QT learning 27 application
随机推荐
Call pytorch API to complete linear regression
Dedecms collects content without writing rules
Interactive book delivery - signed version of Oracle DBA work notes
offer收割机:两个长字符串数字相加求和(经典面试算法题)
Linux server development, MySQL index principle and optimization
海信电视开启开发者模式
漏洞复现-easy_tornado
Lattice coloring - matrix fast power optimized shape pressure DP
青龙面板-今日头条
积分商城管理系统中应包含的四大项
Content of string
[step on the pit series] H5 cross domain problem of uniapp
[untitled]
Leetcode 187 Repeated DNA sequence (2022.07.06)
eBPF Cilium实战(1) - 基于团队的网络隔离
Force buckle 144 Preorder traversal of binary tree
The charm of SQL optimization! From 30248s to 0.001s
太真实了,原来自己一直没有富裕起来是有原因的
JS cross browser parsing XML application
ZCMU--1396: 队列问题(2)