洛谷OJ: P1508 Likecloud-吃、吃、吃

从零构建:如何在VSCode中为HBuilderX迁移的UniApp项目搭建TypeScript支持环境 本文详细指导如何将HBuilderX中的UniApp项目迁移至VSCode并搭建TypeScript支持环境。通过pnpm包管理器初始化项目、配置tsconfig.json和vite.config.ts文件,实现工程化迁移与TypeScript深度集成,提升开发效率和代码质量。 阅读详情

思路:一题非常直观的DP,直接就可以列出动态转移方程

dp[i][j] = dp[i][j] + max{dp[i-1][j-1], dp[i-1][j], dp[i-1][j+1]};

即向左前方走,向前走,向右前方走

说来和校OJ那题走运的zzz简直一模一样呢,不过这题有个坑点就是"每组数据的出发点都是最后一行的中间位置的下方!",所以最后的答案应该是最下面一行最中间的三格中最大的那个值

/**
 *	题目: 洛谷OJ: P1508 Likecloud-吃、吃、吃
 *	题型: DP
 **/
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int maxn = 200+10;
int dp[maxn][maxn], n, m;
int main()  {
    memset(dp, -0x3f, sizeof(dp));
    /************input**************/
    cin >> m >> n;
    /*******************************/
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= n; j++) {
            cin >> dp[i][j];
            if(i-1) dp[i][j] += max(dp[i-1][j-1], max(dp[i-1][j], dp[i-1][j+1]));
        }
    }
    cout << max(dp[m][n/2], max(dp[m][n/2+1], dp[m][n/2+2])) << endl;
    return 0;
}

图学习——04.HAN(异构图注意力网络) 什么是异构图,什么是元路径,什么是HAN,怎么计算attention,节点级别的attention和语义级别的attention 阅读详情

相关推荐

应急响应之windows日志分析工具logparser使用

windows日志分析工具logparser使用介绍

u013930899的博客 8133

洛谷1508 Likecloud-吃、吃、吃

题目背景 问世间,青春期为何物? 答曰:“甲亢,甲亢,再甲亢;挨饿,挨饿,再挨饿!” 题目描述 正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一直处在饥饿的状态中。某日上课,正当他饿得头昏眼花之时,眼前突然闪现出了一个n*m(n and m<=200)的矩型的巨型大餐桌,而自己正处在这个大餐桌的一侧的中点下边。餐桌被划分为了n*m个小方格,每一个方格中都有一个圆形的巨型大餐...

weixin_34250709的博客 276

紫光同创PGL50H开发板实战:盘古50KH视频板的多媒体处理与高速通信方案

本文详细介绍了基于紫光同创PGL50H FPGA芯片的盘古50KH视频开发板在多媒体处理与高速通信方面的实战应用。文章从开发板硬件架构解析入手,逐步指导开发环境搭建、DDR3内存控制器配置、HDMI视频输入输出实战,并重点探讨了利用板载HSST高速收发器实现光纤通信与万兆以太网的方案。最后,通过构建一个集多路视频采集、处理与光纤传输于一体的系统案例,展示了该开发板在高性能实时数据处理领域的强大潜力。

b9c0d的博客 491

【洛谷】P1508 Likecloud-吃、吃、吃(多维动态规划)题解

原题地址:https://www.luogu.org/problem/P1508 题目描述 正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一直处在饥饿的状态中。某日上课,正当他饿得头昏眼花之时,眼前突然闪现出了一个nm(n and m<=200)的矩型的巨型大餐桌,而自己正处在这个大餐桌的一侧的中点下边。餐桌被划分为了nm个小方格,每一个方格中都有一个圆形的巨型大餐盘,上面盛满了...

360°顺滑 532

从零配置ORB-SLAM3:TUM-VI数据集yaml文件参数调优指南

本文深入解析了ORB-SLAM3在TUM-VI数据集上的yaml配置文件参数调优方法。针对双目惯性模式,详细拆解了相机标定、IMU噪声模型和ORB特征提取三大模块的关键参数,解释了其原理与影响,并通过实战案例展示了如何通过调整特征点数量、FAST阈值及IMU噪声参数,有效提升系统在低纹理环境下的鲁棒性和轨迹精度。

weixin_29071809的博客 154

【数字逻辑电路课程设计】多功能数码管时钟VHDL+quartus II-EP1C12F324C8+源码+付费资源

我希望需要我这篇文章的是正常学习数字逻辑课程且正在设计数码管时钟的同学。我个人不推荐直接获取源代码,因此我另有一份付费资源是完整源代码;我推荐各位去研究我代码的逻辑尝试自己书写属于自己的代码,因此我保留了注释但隐去了变量。由于时间有限,我的设计不够完美,仍有很多缺陷,我将我的展望写在后面,各位可以尝试实现。我不为难同学,作为同学我理解各位设计的辛苦,因此如果有需要,私信我提供隐去敏感信息的学生证照片可直接获取源代码。

WannaFlysyx的博客 1536

P1508 Likecloud-吃、吃、吃

暴力递归到记忆化搜索:从40分到100分的过程 暴力递归思路:这个人每次吃只能吃前方,左前方,右前方,一共有三个状态,变化参数为坐标,从n+1行开始到0行,(1~n为食物摆放),设f(x,y)表示从x,y出发,吃完的最大能量值,暴力解题如下: #include<bits/stdc++.h> #define MAX 205 using namespace std; int n,m; int arr[MAX][MAX]; int process(int x,int y) { /*if(d..

qq_45768588的博客 1088

深度学习与西储大学轴承数据集(一)

西储大学数据集介绍

weixin_50642818的博客 1万+

洛谷多维DP(1):P1508 Likecloud-吃、吃、吃——有效数字的判断处理

输入输出样例 输入 #1复制 6 7 16 4 3 12 6 0 3 4 -5 6 7 0 0 2 6 0 -1 -2 3 6 8 5 3 4 0 0 -2 7 -1 7 4 0 7 -5 6 0 -1 3 4 12 4 2 输出 #1复制 41 总结目录 1.状态方程的获取 2.有效数字的判断以及初始化 1 状态方程的获取 我们知道最终是获得最上面的时候的最大能量值,从下面开始吃起。容易想到...

qq_35299223的博客 339

【医学图像处理】X-ray成像之X射线的产生

【医学图像处理】X-ray成像之X射线的产生 概述 电流流过钨丝,并将其加热。 随着加热,增加的能量使电子能够通过热电子发射从灯丝中释放出来。 电子被吸引到带正电的阳极,并以由管电位(电压)确定的最大能量撞击钨靶。 当电子轰击目标时,它们通过轫致辐射和特有的相互作用将能量转换为热量(99%)和X射线光子(1%)。 X射线光子以一束能量(X射线光谱)从光束中释放出来,构成X射线图像形成的基础。 设备 阴极 灯丝 用细的(0.2毫米)钨丝制成,因为钨: 原子序数高(A 184,Z 74) 是良好的热

ZhangPY的专栏 2363

Microsoft Bitlocker企业级管理部署方案

BitLocker是Windows 10以及更高版本中内置的磁盘加密工具,是一种可靠的数据保护机制,可以保护计算机上的敏感数据不被未经授权的人访问。BitLocker的工作原理是将整个系统卷或其他数据卷加密的同时,向某个可信软件或硬件模块请求密钥解密数据。BitLocker最大的好处在于其内置于Windows系统,所以用户无需安装其他软件或购买额外的许可证或硬件设备。本文将介绍Microsoft BitLocker企业级管理部署方案,包括:BitLocker部署前的准备工作。

xueyunshengling的博客 2079

Likecloud—吃、吃、吃(P1508)

[洛谷1508]Likecloud—吃、吃、吃

cggwz的信息飞船 466

[SV]SystemVerilog中,系统函数$cast()的作用是什么?

摘要:SystemVerilog中的$cast()系统函数用于安全的动态类型转换,主要在类层次结构中将父类句柄转换为子类句柄(向下转换)。它通过运行时类型检查确保转换合法性,成功时返回1并赋值句柄,失败则返回0。这种机制使得可以通过父类句柄访问子类特有成员,在多态场景(如UVM验证)中尤为重要。使用时需检查返回值处理转换失败情况。$cast()比静态转换更安全,但不能用于无关类或基本数据类型间的转换。

元直的博客 1225

洛谷 P1508 Likecloud-吃、吃、吃 动规

题目链接: 点我跳转 题目大意: 给定一个矩阵,从最下方正中间一点出发,可以向上、左上、右上前进,寻找一条路径,使得路径上数字和最大。 题目分析: 也就是个数字金字塔的变形(不懂数字金字塔的百度吧。。。点这里) #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;vector&gt;...

ChenyangDu的博客 332

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

深度学习工具包 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")

洛谷 P1508 Likecloud-吃、吃、吃 (记忆搜/dp

题目链接 https://www.luogu.org/problemnew/show/P1508 题意: 很裸的dp思想, 这里用记忆化搜索从上向下的搜索储存 递推的写法更加方便 记忆化搜索 #include &amp;lt;bits/stdc++.h&amp;gt; using namespace std; #define cpp_io() {ios::sync_with_stdio(false); ...

Yishui_lovely 298

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

[洛谷] P1508 吃吃吃

简单DP 注意最后取值即可 //#pragma GCC optimize(2) #include &lt;cstdio&gt; #include &lt;iostream&gt; #include &lt;cstdlib&gt; #include &lt;cmath&gt; #include &lt;cctype&gt; #include &lt;string&gt; #include ...

Zeolim的博客 322

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

AtCoder Beginner Contest 256

AtCoder Beginner Contest 256

青少年趣味编程 794

Likecloud-吃、吃、吃

做题记录

hhh1yyy1的博客 347

P1508-Likecloud-吃、吃、吃

1 #include <bits/stdc++.h> 2 #define maxn 13003 3 #define _for(i,a,b) for(int i = (a);i < b;i ++) 4 typedef long long ll; 5 using namespace std; 6 inline ll read() 7 { 8...

weixin_30836759的博客 158

洛谷 1508 Likecloud-吃、吃、吃

http://dev.luogu.org:3308/problem/show?pid=1508#sub 比较水的一个DP,初始位置在a[m][n/2+1]的下方,所以起点只能是a[m][n/2]或a[m][n/2+1]或a[m][n/2+2],转移方程比较显然是f[i][j]=max{f[i+1][j-1],f[i+1][j],f[i+1][j+1]}+a[i][j]就完事了。。。#include

sdxtcqs的博客 332

【洛谷OJ】积木大赛(为毛提高组会有这种水题)

题目描述 春春幼儿园举办了一年一度的“积木大赛”。今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第i块积木的最终高度需要是h_i 。 在搭建开始之前,没有任何积木(可以看成n块高度为0的积木)。接下来每次操作,小朋友们可以选择一段连续区间[l, r],然后将第第 L块到第 R 块之间(含第 L 块和第 R块)所有积木的高度分别增加1。 小 M 是个聪明的小朋友,...

潜伏 的博客 373

【洛谷】P1508 Likecloud-吃、吃、吃

题目地址: https://www.luogu.com.cn/problem/P1508 题目背景: 问世间,青春期为何物?答曰:“甲亢,甲亢,再甲亢;挨饿,挨饿,再挨饿!” 题目描述: 正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一直处在饥饿的状态中。某日上课,正当他饿得头昏眼花之时,眼前突然闪现出了一个n×m(n,m≤200)n \times m(n,m \le 200)n×m(n,m≤200)的矩型的巨型大餐桌,而自己正处在这个大餐桌的一侧的中点下边。餐桌被划分为了n×mn \times

数学、算法爱好者的博客 274

【洛谷 1508】 Likecloud-吃、吃、吃

思路数字三角形变式,每个点从上边、左上和右上转移而来。代码#include <iostream> #include <cstdio> using namespace std; const int inf = 1e9; int a1[210][210], f[210][210], n, m; int b1[] = {0,-1,-1,-1,0}; int b2[] = {0,0,1,-1,0}; boo

yhf_2015 413

Likecloud 吃吃吃

逆推法。 一个格子是从上面的左中右搞来的。 最后多推一次,求上面三个格子的最大值。#include <cstdio> #include <iostream> #include <cstring> using namespace std; int map[999][999]; int dp[999][999]; int main() { memset(dp,128,sizeof(dp));

HT008的Blog 402

[线性DP] 洛谷P1508 Likecloud-吃、吃、吃(多阶段决策)

题目 LP1508 思路 紫书例题单向TSP翻版,甚至还更简单。 启示 oi不能瞧不起简单题。 一上场,一看普及/提高-,一看是单向TSP翻版,就想这水题我十分钟秒。。然后拖了一个小时。。 总之OI作为一项高技术难度的活动,即便是很简单的题,也应该有足够的思考和谨慎,再简单的题,像边界处理,小数精度,负数下标访问,字符串这些零零碎碎的东西也会直接让代码WA或者RE。有句话叫,当你...

OI - IceCab 263

洛谷 P1508 Likecloud-吃、吃、吃

这道题题好像写麻烦了 因为道路从上到下和从下到上是一样的 所以可以从上推到下,然后按照水牛开始位置输出结果。 我是直接模拟水牛的移动,代码多了些。 然后记住memset是必要的,不要省略,可能有负的情况 #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;algorithm&gt; #define REP(i, a, b) fo...

自强不息 厚德载物 206
上一篇: 洛谷OJ:P1855 榨取kkksc03(DP)
下一篇: 洛谷OJ: P1387 最大正方形(DP)
h4ms7er
博客等级 码龄9年 31粉丝 60原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值