洛谷p1004方格取数

洛谷 P1004 方格取数 Java 洛谷 P1004 方格取数 题目 设有 N×N 的方格图(N≤9),我们将其中的某些方格中填入正整数,而其他的方格中则放入数字 0。如下图所示(见样例): A 0 0 0 0 0 0 0 0 0 0 13 0 0 6 0 0 0 0 0 0 7 0 0 0 0 0 0 14 0 0 0 0 0 21 0 0 0 4 0 ... 阅读详情

用一个四维数组来记录,dp[i][j][k][l] , 第一个人走到i,j取得的最大值, 第二个人走到k,l取到的最大值

#include <cstdio>
#include <algorithm>
using namespace std ;
const int N = 15 ; 
int maze[N][N] ;	
int dp[N][N][N][N] ; 
int n ; 

int main(){
	scanf ("%d",&n) ;
	int x , y , v ; 
	while(~scanf("%d%d%d",&x,&y,&v)){
		if (x == 0 && y==0 && v==0)
			break ;
		maze[x][y] = v ;  
	} 
	for (int i = 1 ; i <= n ; ++i){
		for (int j = 1 ; j <= n ; ++j){
			for (int k = 1 ; k <= n ; ++ k){
				for (int l = 1 ; l <= n ; ++l){
					dp[i][j][k][l] = max(max(dp[i-1][j][k-1][l],dp[i][j-1][k][l-1]),max(dp[i][j-1][k-1][l],dp[i-1][j][k][l-1]))
					        + maze[k][l] + maze[i][j] ; 
					if (i == k && j == l){
						dp[i][j][k][l] -= maze[i][j] ; 
					}
				}
			}
		}
	}
	printf ("%d\n",dp[n][n][n][n]) ; 
	return 0 ;
}
极空间NAS小白也能搞定的Gitea部署:Docker+MySQL避坑全记录 本文为极空间NAS用户提供了一份详尽的Gitea私有代码仓库部署指南。针对极空间ARM架构和图形化Docker管理的特殊性,文章重点讲解了如何通过Docker和MySQL容器进行部署,并提供了三种获取兼容镜像的实战策略,特别是利用第三方镜像站转录的方法,帮助小白用户成功搭建并初始化Gitea服务,实现私有Git托管。 阅读详情

相关推荐

从零开始:手把手教你用Verilog搭建一个可配置的Cache模块(以Vortex GPGPU为例)

本文详细介绍了如何使用Verilog从零开始搭建一个可配置的Cache模块,以Vortex GPGPU为例。内容涵盖Cache设计基础、模块接口与参数化设计、核心子模块实现、仲裁与一致性机制、功能验证与性能调优等关键环节,适合RTL设计初学者和希望深入理解Cache工作原理的工程师。通过实战指南,读者可以掌握硬件代码分析技巧,提升Cache模块的设计能力。

weixin_42552315的博客 441

【洛谷】P1004 方格取数

题目链接 题目描述 设有N×N的方格图 (N≤9),我们将其中的某些方格中填入正整数,而其他的方格中则放入数字0。如下图所示(见样例): 0 0 0 0 0 0 0 0 0 0 13 0 0 6 0 0 0 0 0 0 7 0 0 0 0 0 0 14 0 0 0 0 0 21 0 0 0 4 0 0 0...

悲伤无声地涌出来 1643

基于Landsat-8数据的山西省吕梁市地表温度反演研究过程(大气校正法)

1.数据下载:本实验采用的数据是 ①从地理空间数据云下载的来自landsat8 卫星,云量<=1%,时间为2017年5月12日的山西省吕梁市影像数据。为全面覆盖吕梁市,选用了两片影像。 ②吕梁市边界矢量图 2.数据预处理 ...

weixin_45747376的博客 6601

洛谷1004——方格取数

思路: 由于需要取2条路径最大值之和,且取完该位置数为0,因此两条路径相互影响,需要将两次路径看作两个人同时取数,使用四维dp数组,f[i][j][k][l]表示第一个人走到(i,j),第二个人走到(k,l)时最大取数之和 。 代码: #include <bits/stdc++.h> using namespace std; //f[i][j][k][l]表示第一个人走到(i,j),第二个人走到(k,l)时最大取数之和 int main() { int n,i,j,k,l,x,y,m; ..

qq_45626896的博客 533

AI视频生成技术研究报告:现状、挑战与展望

AI 视频生成技术概述:介绍 AI 视频生成技术的基本概念,回顾其发展历程,从早期依赖图像拼接的简单生成方式,到如今融合多种先进技术的复杂模型应用,梳理技术演进的关键节点和重要突破。同时,分析该技术在当前阶段的特点,包括生成视频的质量、速度、灵活性等方面,以及与传统视频制作方式的差异,阐述 AI 视频生成技术如何改变视频创作的流程和模式。技术实现路径分析。

daqsdfas的博客 4588

保姆级教程:用STM32单片机实现国标交流充电桩的CP信号检测(附完整代码)

本文详细介绍了基于STM32单片机实现国标交流充电桩CP信号检测的全流程,包括硬件设计、软件架构和充电控制实现。通过分压电路设计、ADC配置和状态机逻辑,确保充电过程的安全与可靠性,适用于新能源汽车充电桩开发。附完整代码和调试技巧,助力开发者快速掌握关键技术。

weixin_42641998的博客 252

【洛谷】P1004 [NOIP2000提高组]方格取数

如果各个子问题不是独立的(即重复的),且不同子问题的个数是有限的,那么如果我们可以保存已经解决的子问题的答案,而在需要时再找出已经求得的答案,这样就可以避免大量的重复计算,以此减少时间复杂度。2.dp[m1][n1][m2][n2]处的最大取数值取决于四个值中的最大值,分别为两个路径各自从左、上两个方向传入的值。在走过的路上,他可以取走方格中的数(取走后的方格中将变为数字 0)。输入的第一行为一个整数 N(表示 N×N 的方格图),接下来的每行有三个整数,前两个表示位置,第三个数为该位置上所放的数。

2302_80216196的博客 825

基于 FPGA 的 CNN 卷积神经网络之池化层 Verilog 实现

池化层是卷积神经网络(CNN)中的关键组件,用于降低特征图的维度,减少计算量和防止过拟合。常见的池化操作包括最大池化和平均池化。FPGA 提供了高效的并行处理能力,可以加速这些操作。池化层在 CNN 中扮演重要角色,通过降低数据维度提升计算效率。在 FPGA 上实现池化层,可以充分利用硬件资源实现高效的并行计算,有助于提高实时应用中的推理速度。

走向CTO的路上... 1256

[洛谷]P1004 方格取数 (#动态规划 -2.1)

题目描述 设有N \times NN×N的方格图(N \le 9)(N≤9),我们将其中的某些方格中填入正整数,而其他的方格中则放入数字00。如下图所示(见样例): A 0 0 0 0 0 0 0 0 0 0 13 0 0 6 0 0 0 0 0 0 7 0 0 0 0 0 0 14 0 0 0 0 0 21 0 0 0 ...

A.pro的博客 722

Android 14.0 SystemUI下拉通知栏通知去掉长按事件

在14.0的系统rom产品定制化开发中,在systemui模块中关于下拉状态栏这块也是非常重要的部分,最近在关于systemui下拉通知栏的每条通知部分 要求去掉通知栏通知的长按事件,不需要长按功能,所以就需要分析下关于长按事件是在哪里注册的,然后去掉就可以了,接下来分析实现 相关功能

安卓兼职framework和app工程师的博客 277

Allegro输出光绘文件规范

添加钻孔表的具体步骤为:1.通过屏幕右边的Visibility选项的Views列表,将Drill层打开2.将Visibility选项中的PIN和Via选项都选中,见下图所示: 参数设好之后关闭NC Drill/Parameters窗口,输出数控机床钻孔文件的命令菜单为:Manufacture=>NC=>NC Drill…,打开的窗口如下: 输出数控机床钻孔文件的具体步骤为: 上图是光绘输出的层控制窗口,还有一个窗口是输出参数的控制窗口,我们通过点击上图的第二个列表项General Parameters来

axingxiansen的博客 2809

洛谷P1004_方格取数详解

如果你看完了状态转移方程就激动地写完了代码提交,却发现五个WA,很有可能是因为你没有理解题中“ 他可以取走方格中的数(取走后的方格中将变为数字 0)”这句话的含义,如果第一条路走到了一个格子,取走了格子里的数,第二条路刚好又走到了相同的格子上会怎么样呢?我们还是和二维数组走格子一样,但是我们现在假设两个点:假设第一条路走到格子[i,j],第二条路走到格子[m,k],现在就很熟悉了,走到一个格子可能是从他的上面一个格子往下走,也有可能是从他左边一个格子往右走,现在有两个点,那么总共就会有四种走法。

m0_74300099的博客 452

让 ABAP 开发者也能做出高质量 SAP Fiori:到底需要掌握多少前端知识?

文章摘要: 随着SAP技术演进,ABAP开发者的角色边界正在重构。传统SAP GUI时代的全栈开发模式逐渐转向RAP+Fiori Elements的新范式,其中关键技术变化包括: 开发模式转变:从前后端耦合转向RAP模型驱动开发,通过CDS注解实现UI意图表达 分工优化:Fiori Elements模板处理80%标准UI需求,Flexible Programming Model解决20%差异化需求 效率提升:注解驱动开发可在RAP建模阶段同步定义UI结构,大幅缩短交付周期 工具整合:SAP提供从建模到部署的

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 350

洛谷 P1004 方格取数

洛谷 P1004 方格取数 题目描述 设有N \times NN×N的方格图(N \le 9)(N≤9),我们将其中的某些方格中填入正整数,而其他的方格中则放入数字00。如下图所示(见样例): A 0 0 0 0 0 0 0 0 0 0 13 0 0 6 0 0 0 0 0 0 7 0 0 0 0 0 0 14 0 0 0 ...

anynever的博客 344

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

洛谷P1004方格取数(C++)

## **P1004方格取数** **题目描述** 设有N \times NN×N的方格图(N \le 9)(N≤9),我们将其中的某些方格中填入正整数,而其他的方格中则放入数字00。如下图所示(见样例): A 0 0 0 0 0 0 0 0 0 0 13 0 0 6 0 0 0 0 0 0 7 0 0 0 0 0 0 14 0 0 0 0 0 21 0 0 0 4 0

洛谷棕名用户的博客(兔子的博客) 2249

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

洛谷P1004(方格取数[NOIP 2000 提高组])题解

洛谷P1004详解15000字

2201_75316840的博客 1319

洛谷P1004(方格取数)

洛谷P1004   这一题我在做之前是看了题解的,但是好吓人,有人用了4维数组,特别恐怖   时间复杂度姑且不计,n^4空间复杂度就太恐怖了,但是注意到题目的一个性质,就是每个点的值只与前面一次遍历到的点有关,可以再次采用滚动数组的方法   以下是我的代码 #include<iostream> #include <algorithm> #define ll long long using namespace std; ll f[11][11]; ll map[11][11]; int

ly3098268698的博客 448

洛谷P1004 方格取数

洛谷P1004 方格取数 动态规划 多维DP 题目描述 设有N×N的方格图(N≤9),我们将其中的某些方格中填入正整数,而其他的方格中则放入数字0。如下图所示(见样例): A 0 0 0 0 0 0 0 0 0 0 13 0 0 6 0 0 0 0 0 0 7 0 0 0 0 0 0 14 0 0 0 0 ...

weixin_30851409的博客 239

洛谷 P1004 方格取数 Java解法

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int goodness[][] = new int[50][50]; int coordinate[][][][] = new int[11][11][11][11];// x1 y1 x2 y2 int m = sc.nextInt();.

青柠小甜味 365

[洛谷] P1004 方格取数 Apare_xzc dp

[洛谷] P1004 方格取数 题面: 思路:       如果是走一次的话,那是最经典(简单)的动态规划问题。令dp[x][y]表示从起点A到点(x,y)路径的最大和,那么dp转移方程为:、 dp[x][y] = max(dp[x-1][y] , dp[x][y-1]) + a[x][y] 我们贪心地认为走两次的最大值就是第一次的...

Apare_xzc的博客 234

洛谷 P1004 [NOIP 2000 提高组] 方格取数

摘要:本文解决NOIP2000提高组的方格取数问题,要求从N×N方格左上角出发到右下角,走两次路径获取数字之和最大。采用动态规划方法,同时处理两条路径的移动(四种方向组合),使用四维数组记录状态避免重复计算。每次移动时,若路径重叠则减去重复数字。时间复杂度优化至O(N^4),适用于N≤9的情况。最终输出两条路径最优解之和,包含起点数字。算法核心是同时处理两条路径的状态转移,确保全局最优。

2402_86277110的博客 342

洛谷[P1004]方格取数

洛谷[P1004]方格取数 题目描述 设有N*N的方格图(N&lt;=9),我们将其中的某些方格中填入正整数,而其他的方格中则放 人数字0。如下图所示(见样例): A 0 0 0 0 0 0 0 0 0 0 13 0 0 6 0 0 0 0 0 0 7 0 0 0 0 0 0 14 0 0...

weixin_43249938的博客 143
上一篇: 洛谷p1141 01迷宫
下一篇: 洛谷普及场(高精度算法)
coder370
博客等级 码龄8年 4粉丝 75原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值