hdu 5074 Hatsune Miku(dp)

GoDaddy域名解析 到 阿里云域名DNS 一:登录GODaddy,点击“个人中心”,然后点击“管理域名” 二:域名解析 第一种:直接解析到对应的服务器 添加一个,类型默认A,主机填写二级域名前缀(image.主域名),指向填写目标服务器ip即可(注意目标服务器80端口是否开放) 第二种:将主域名dns转到阿里云域名下 三:若要修给为阿里云解析服务器,要做以下修改,点击“更改” 点击更改后出现如下页面,此时需要到阿里云官网云解析DNS下添加域名解析 四:阿里云添加域名解析... 阅读详情

dp[i][j]表示处理到第i位时最后一个数是j的最大价值。

转移就是dp[i][j]=max(dp[i-1][k]+cost[k][j]) (枚举k)


如果遇到给定的数,就把处理到这一位不是这个给定的数的情况全部处理为负无穷,因为是不合法的。初始化时如果第一个数就给定了也是这样处理。

代码:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#define INF (-1000000)
#define LL long long
using namespace std;
int dp[105][55];
int cost[55][55];
int p[105];
int n,m;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;i++){
			for(int j=1;j<=m;j++){
				scanf("%d",&cost[i][j]);
			}
		}
		for(int i=1;i<=n;i++)
			scanf("%d",&p[i]);
		memset(dp,0,sizeof(dp));
		if(p[1]!=-1){
			for(int i=1;i<=m;i++){
				dp[1][i]=INF;
			}
			dp[1][p[1]]=0;
		}
		else {
			for(int i=1;i<=m;i++){
			   dp[1][m]=0;
			}
		}
		
		for(int i=2;i<=n;i++){
			if(p[i]!=-1){
				for(int j=1;j<=m;j++){
					dp[i][p[i]]=max(dp[i-1][j]+cost[j][p[i]],dp[i][p[i]]);
				}
				for(int j=1;j<=m;j++){
					if(j!=p[i]) dp[i][j]=INF;
				}
			}
			else{
				for(int j=1;j<=m;j++){
					for(int k=1;k<=m;k++){
						dp[i][k]=max(dp[i-1][j]+cost[j][k],dp[i][k]);
					}
				}
			}
		}
		int res=0;
		for(int i=1;i<=m;i++){
			res=max(res,dp[n][i]);
		}
		cout<<res<<endl;
	}
	return 0;
}


从AXI到CHI:深入解析基于Credit的流量控制如何优化NoC设计 本文深入解析了从AXI握手式流控到CHI基于Credit的流量控制机制的演进。通过对比传统流控的瓶颈,详细阐述了Credit机制如何通过信用预分配和记账系统,有效解决FIFO气泡、时序收敛等难题,从而优化NoC设计的带宽利用率、降低延迟并提升系统可扩展性。 阅读详情

相关推荐

关于 MCU 芯片外围电路的快速入门介绍

MCU 外围电路的核心是“围绕 MCU 需求,搭建稳定、匹配的外部支撑”,入门阶段无需掌握复杂设计,只需先吃透供电、复位、时钟、IO 驱动、基础通信这五大模块,再逐步扩展存储、显示、传感器等进阶功能。实践中多调试、多参考成熟方案,是快速掌握外围电路设计的关键。码字不易,若觉得本文对你有用,欢迎,相关技术热点时时看🔥🔥🔥​​​…

JiaWen的博客 1646

HDU5074(DP)

比较水的DP。 题意是用m个不同音符创作含n个音符的音乐:a1, a2,a3.......an。要求max (sore(a1,a2)+sore(a2,a3)+...+sore(an-1, an))。 用dp[i][j]表示第i个音符使用j的最大价值,max (a[n][k] | 1 #include #include #include #include #include #incl

morejarphone~ 559

全桥LLC谐振变换器设计与双环控制策略详解

LLC谐振变换器作为高频开关电源的核心拓扑,通过谐振腔实现软开关特性,显著提升转换效率(可达96%以上)。其工作原理基于谐振电感、电容的协同作用,当开关频率接近谐振点时实现ZVS/ZCS。在工业电源、电动汽车充电等场景中,电压电流双环控制策略通过引入电流内环和竞争仲裁机制,有效改善动态响应(实测负载跳变时电压跌落减少60%)。数字控制实现时需注意ADC采样同步和PWM更新时序,而谐振参数测量与温升管理则是工程实践的关键。

weixin_29189987的博客 257

hdu5074 Hatsune Miku 2014鞍山现场赛E题 水dp

http://acm.hdu.edu.cn/showproblem.php?pid=5074 Hatsune Miku Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 325    Accepted Submission(s

689

深圳SILAS(智能融合低空系统)无人机调度系统介绍

一、系统定位与核心目标SILAS(Smart Integrated Lower Airspace System)是深圳市为低空经济打造的“数字大脑”,由粤港澳大湾区数字经济研究院自主研发,定位为城市级低空飞行智能调度与管理平台。核心目标是解决低空经济中“高密度、高复杂度、多主体”的飞行调度难题,实现空域资源的高效分配、飞行安全的智能监管及全场景服务的无缝协同,支撑深圳从“无人机之都”向“天空之城”升级。二、核心架构:低空基础设施“四张网”设施网。

主攻大数据 人工智能 物联网 安全 低空经济等方向。mtsc 、gtest特邀分享嘉宾 3747

RK3588 EVB开发板原理图讲解【六】

该原理图展示了eMMC Flash与主控芯片之间的连接关系,以及相关的电源、信号线路和去耦电容等。

weixin_48721556的博客 1174

hdu5074 Hatsune Miku(简单dp)

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5074 题目大意: 给一个m*m的矩阵,有n个数a[i]。然后定义score(i,j)是矩阵第i行第j列的值,i,j分别是a[i]和a[i+1]。现在给出了n个数a[i],如果a[i]是-1,那么就可以把a[i]变成1~n里面的任意一个数。现在问能得到的最大分数是多少。 思路: 简单的d

hahahaha 1006

【08】C#实战篇——C#调用C++ 动态库dll,报错 “无法加载DLL“xxx.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。”

摘要: 本文详细分析了C#调用C++封装的DLL时出现“无法加载DLL”错误的排查与解决方法。通过案例演示,列举了常见原因(如平台不匹配、路径错误、依赖缺失等),并重点介绍了使用VS的dumpbin工具检测DLL依赖项的方法。最终定位问题为缺失依赖的LineApi.dll和opencv_world455d.dll,将其放入C#的exe目录后解决。文章还对比了C++与C#的报错差异,提供了通用解决方案,包括检查运行时库、环境变量等,帮助开发者高效解决类似问题。 关键词: C#调用C++ DLL、dumpbin

程序员,他们想的是什么?他们想的永远都是技术,他们崇尚的也永远都是技术。 2099

HDU 5074 Hatsune Miku DP

解题思路: 题意为有m种音符,编号1到m,我们要用这m种音符来创造一首带有n个音符的曲子(当然,一种音符可以用多次),假设有两个连续的音符 i ,j ,那么定义score(i,j)为这两个音符的得分,题目中预先给出所有的score(i,j)   1<=i,j<=m, 那么我们创造出的n个音符的曲子的得分为  score( note[i] , note[i+1] ) + score (note

Fighting_Dream 560

2024顶级提示工程工具:提升效率的12个神器

LlamaIndex虽然本身不是直接的提示词编辑工具,但其整个设计都围绕着如何有效地将外部知识融入LLM的提示词。它提供了结构化的方式来管理“上下文窗口”——即哪些私有数据应该被包含在提示词中。通过优化索引结构和检索策略,可以确保提示词中包含最相关、最高质量的上下文信息,从而大幅提升LLM基于私有数据回答问题的准确性和相关性。同时,LlamaIndex允许开发者针对不同的查询类型和数据特点定制提示词模板,这使得提示词的复用和优化更加系统化。

AIGC应用创新大全的博客 1099

Arduino ESP32S3开发环境搭建 ------ 在线下载安装包Failed解决方案

本文介绍了Arduino ESP32 S3开发环境搭建的离线解决方案。

张一西的博客 1018

HDU 5074 Hatsune Miku(暴力+DP)

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5074 思路:暴力+DP AC代码: #include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f

Java识堂,一个有干货的微信公众号 603

网络分析工具Wireshark系列专栏:01-专栏导读

随着人工智能技术的普及,越来越多的博主开始利用AI进行内容创作,导致优快云等平台上充斥着大量低质量的洗稿文章,严重影响了技术软文的质量和可信度。为了应对这一现象,提升技术内容的质量,瑞哥决定推出系列技术专栏,为大家带来系统、深入且高质量的技术学习资源。这些专栏将帮助读者从入门到精通,特别适合习惯通过文档学习的技术爱好者。作为首个专栏,我们将聚焦于Wireshark——一款广受欢迎的网络协议分析工具。根据优快云后台的反馈,许多读者表示Wireshark是他们欠缺的一项技能。因此,本专栏将通过精心设计的课程

网络技术联盟站 359

hdu5074 Hatsune Miku dp

hdu5074 Hatsune Miku

u014445884的专栏 420

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

HDU 5074 Hatsune Miku(简单二维dp)

题目大意:给你一些音符之间的联系,给你一个串,让你求出这个串的最大值。-1的时候可以任意替代,其他情况必须为序列上的数。 解题思路:简单二维dp,分情况处理就可以了啊。 Hatsune Miku Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Su

I am a slow walker, but I never walk backwards! 1082

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

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

hdu 5074 Hatsune Miku(dp)

题目连接:hdu 5074 Hatsune Miku 题目大意:给定给一个M∗M的矩阵,以及一个长度为N的数组,每次取G[a[i]][a[i+1]]的值,如果a[i]为-1则可以是任何数,问说最大值。 解题思路:dp[i][j]表示第i个数为j的时候的最优解,如果a[i]不为-1,那么j = a[i],否则枚举j。 #include #include #include usi

不慌不忙、不急不躁 777

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

hdu 5074 Hatsune Miku【DP】

Hatsune Miku Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1495    Accepted Submission(s): 1015 Problem Description Hatsune Miku is

mengxiang000000 1万+

HDU 5074 Hatsune Miku(DP)

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5074 题目大意:给定一个长度为n的序列c[i],该序列为一个乐谱。我们的任务是要给这个序列补上音符。c[i]的数值有两种情况:-1、不是-1。不是-1的这个位置的音符已经确定,不能再更改。是-1的这个位置音符可以任意选择。可以选择的音符有m种,编号为1-m。              当乐谱序列

cxhscst2 352

HDU 5074 Hatsune Miku 【dp思维】

传送门 //题意: 给一个m*m的矩阵, 有n个数a[i]. 然后定义score(i,j)是矩阵第i行第j列的值, i, j分别是a[i]和a[i+1]. 现在给出了n个数a[i], 如果a[i]是-1, 那么就可以把a[i]变成1~n里面的任意一个数。现在问能得到的最大分数是多少.//思路: 简单的dp. 设dp[i][j]代表前i个数最后一个为j时的最大分数 所以只需要分两种情况讨论下就可以

Anxdada -- 我等风来也等你 591

HDU 5074 Hatsune Miku (线性dp)

HDU 5074 Hatsune Miku (线性dp) 2014acm鞍山区域赛

Tc的专栏 1565

hdu 5074 Hatsune Miku 简单dp

题意:给出m*m的分值表和一个序列(其中有些位置待填),求总分值的最大值。总分值=序列中相邻元素的分值之和。解法:dp[i][x]表示考虑了前i个序列且最后一个为x的最优值。代码:#include<cstdio> #include<string> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #inc

便纵有千种风情 466

hdu5074Hatsune Miku dp水题

#include #include #include using namespace std ; const int maxn = 110 ; int dp[maxn][maxn] ; int ss[maxn][maxn] ; int a[maxn] ; int main() { int t ; scanf("%d" , &t) ; while(t--) {

ijbuhv的专栏 538

Hatsune Miku HDU-5074 DP

Hatsune Miku code #include <bits/stdc++.h> using namespace std; int sco[110][110]; int idx[110]; int dp[110][110]; void solve() { int o; cin >> o; while(o --) { int n, m; cin >> n >> m; for(int i =

qq_46173805的博客 1242

HDU 5074 Hatsune Miku 暴力dp

点击打开链接 Hatsune Miku Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 677    Accepted Submission(s): 490 Problem Description

代码改变世界,keep coding。 1171

hdu 5074 Hatsune Miku DP题目

题目传送门http://acm.hdu.edu.cn/showproblem.php?pid=5074 $dp[i][j] =$ 表示数列前$i$个数以$j$结尾的最大分数 $dp[i][j] = -1$ 表示不可能取到。 当$b[i] = -1$ 时: $$dp[i][j] = \max(dp[i][j],dp[i-1][k] + scores[k][j])$$ $$(...

weixin_30566149的博客 136

HDU 5074 Hatsune Miku(DP)

Problem Description Hatsune Miku is a popular virtual singer. It is very popular in both Japan and China. Basically it is a computer software that allows you to compose a song on your own usi...

weixin_30345055的博客 67
上一篇: hdu 5071 Chat(模拟)
下一篇: hdu 5073 Galaxy(数学+前缀和)
Baoli1008
博客等级 码龄12年 70粉丝 293原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值