当前位置:网站首页>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;
}边栏推荐
- [quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
- Ansible
- 【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
- 青龙面板-今日头条
- 【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习
- 数据库实时同步利器——CDC(变化数据捕获技术)
- JS quick start (I)
- Paddlepaddle 29 dynamically modify the network structure without model definition code (relu changes to prelu, conv2d changes to conv3d, 2D semantic segmentation model changes to 3D semantic segmentat
- 这5个摸鱼神器太火了!程序员:知道了快删!
- Force buckle 145 Binary Tree Postorder Traversal
猜你喜欢

Record a stroke skin bone error of the skirt

【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)

Who has docker to install MySQL locally?

2022 tea master (intermediate) examination questions and mock examination
![[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)](/img/e1/9a047ef13299b94b5314ee6865ba26.png)
[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)

2022 welder (elementary) judgment questions and online simulation examination

2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案

Es FAQ summary

【數字IC驗證快速入門】15、SystemVerilog學習之基本語法2(操作符、類型轉換、循環、Task/Function...內含實踐練習)

Yugu p1020 missile interception (binary search)
随机推荐
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
Chip information website Yite Chuangxin
Network learning (III) -- highly concurrent socket programming (epoll)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
Binary tree and heap building in C language
[VHDL parallel statement execution]
快速使用 Jacoco 代码覆盖率统计
Leetcode 90: subset II
The charm of SQL optimization! From 30248s to 0.001s
OpenJudge NOI 2.1 1752:鸡兔同笼
game攻防世界逆向
JS quick start (I)
Paddlepaddle 29 dynamically modify the network structure without model definition code (relu changes to prelu, conv2d changes to conv3d, 2D semantic segmentation model changes to 3D semantic segmentat
Chip design data download
Thinkcmf6.0 installation tutorial
青龙面板-今日头条
mysql多列索引(组合索引)特点和使用场景
Linux server development, MySQL transaction principle analysis
2022 welder (elementary) judgment questions and online simulation examination
paddlepaddle 29 无模型定义代码下动态修改网络结构(relu变prelu,conv2d变conv3d,2d语义分割模型改为3d语义分割模型)