当前位置:网站首页>ZCMU--1492: Problem D(C语言)
ZCMU--1492: Problem D(C语言)
2022-07-07 05:05:00 【小小小Why】
Description
Chieh最近在网上看到蓝翔非常火热。不知为什么他想到了一个问题,有一个n*m的矩阵
每一个小块里有k个石头。。现在挖掘机在左上角,挖掘机非常强大。。可以放无限的石头
但是它只能往右或者往下移动,现在Chieh想知道最多的石头从左上角到右下角。
Input
T 组数 T<=100
n m 1<=n. m<=1000
n行m个数 为石头数量 0<=s<=1000
Output
对于每组测试数据,输出对应的答案。
Sample Input
Sample Output
#include <stdio.h>
#include <string.h>
int f[1005][1005]={0};
int max(int a,int b){ //max函数
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]);//选取左边和上面中最大的一方
}
}
printf("%d\n",f[n][m]);
memset(f,0,sizeof(f)); //记得初始化0,不然会有残留,导致下一组数据出现错误
}
return 0;
}
边栏推荐
- Linux server development, MySQL index principle and optimization
- You Li takes you to talk about C language 6 (common keywords)
- Avatary的LiveDriver试用体验
- [UVM practice] Chapter 2: a simple UVM verification platform (2) only driver verification platform
- Implementation of replacement function of shell script
- The element with setfieldsvalue set is obtained as undefined with GetFieldValue
- The principle and implementation of buffer playback of large video files
- C语言队列
- uniapp 移动端强制更新功能
- Search for an element in a binary search tree (BST)
猜你喜欢
Thinkcmf6.0 installation tutorial
Implementation of replacement function of shell script
Qt学习27 应用程序中的主窗口
2022 Inner Mongolia latest advanced fire facility operator simulation examination question bank and answers
数据库实时同步利器——CDC(变化数据捕获技术)
Empire CMS collection Empire template program general
调用 pytorch API完成线性回归
LeetCode简单题之字符串中最大的 3 位相同数字
3D reconstruction - stereo correction
Thinkcmf6.0安装教程
随机推荐
Numbers that appear only once
Leetcode 40: combined sum II
Qt学习28 主窗口中的工具栏
力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
[UVM practice] Chapter 1: configuring the UVM environment (taking VCs as an example), run through the examples in the book
Network learning (III) -- highly concurrent socket programming (epoll)
C语言队列
Explore Cassandra's decentralized distributed architecture
追风赶月莫停留,平芜尽处是春山
Cnopendata American Golden Globe Award winning data
Content of string
Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)
2022 tea master (intermediate) examination questions and mock examination
复杂网络建模(二)
Find the mode in the binary search tree (use medium order traversal as an ordered array)
Linux server development, redis protocol and asynchronous mode
数据库实时同步利器——CDC(变化数据捕获技术)
Dedecms collects content without writing rules
Visualization Document Feb 12 16:42
2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers