sgu183 Painting the balls_dp

DRV8818+PIC18F96J94实现高确定性步进电机闭环控制 步进电机驱动常被误认为开环系统,实则高性能闭环控制可媲美伺服精度。其核心在于电流环响应速度、硬件级时序协同与热漂移补偿能力——DRV8818PWPR凭借片内镜像电流检测实现<3.5μs超低延迟电流闭环,而PIC18F96J94通过ECCP硬件PWM与PPS引脚重映射达成微秒级确定性时序控制。这种组合规避了RTOS调度抖动与通信协议开销,在资源受限工业场景中保障了位置重复精度±0.002°与电流控制误差<±3.2%。典型应用于精密调焦、协作机器人关节、AGV微步定位等对确定性要求严苛的嵌入式运动控制场景。 阅读详情
#include <iostream>
#include <cstring>
#include <cstdio>
//F[i, j] = c[j] + min {F[k, i])  ( j - M < k < i}
using namespace std;
const int N=105;
const int inf=0x3fffffff;
const int MAXN=10005;
int n,m,c[MAXN],dp[N][N];//sgu限内存,dp不能开大,下面%N优化
void init(int f[]){
    for(int i=0;i<N;i++)
        f[i]=inf;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) scanf("%d",c+i);
    for(int i=1;i<=m;i++)init(dp[i]);
    for(int i=1;i<=m;i++)
        for(int j=1;j<i;j++)dp[i][j]=c[i]+c[j];
    for(int i=m+1;i<=n;i++){
        init(dp[i%N]);//%N的妙处
        for(int j=i-m+1;j<i;j++)for(int k=i-m;k<j;k++)
        dp[i%N][j%N]=min(dp[i%N][j%N],dp[j%N][k%N]+c[i]);//pay attention to 下标起始位置
    }
    int ans=inf;
    for(int i=n-m+2;i<=n;i++)//看懂的恢复下
        for(int j=n-m+1;j<i;j++)
        ans=min(dp[i%N][j%N],ans);
    cout<<ans<<endl;
    return 0;
}

工业互联网工控安全与工业质检AI大模型建设方案.pptx 立即下载

相关推荐

2024 《计算机网络》实验教学指导书.doc

2024 《计算机网络》实验教学指导书.doc

SGU183 Painting the balls(DP+优化)

给出n个白球,每个球有一个涂色的费用,要求任意连续m个球中至少有两个黑球,求最少的涂色费用。 由于连续m个球中至少有两个黑球,我们不难得到递推式f(i,j) = min{ f(j,k) | i > j > k >=  i-m} + c[i] ,表示当前给第i个球涂色,上一个给第j个球涂色的最小费用。这个递推式的时间复杂度为O(N*M^2),由于SGU大多数都是卡时间的神题,我们为了追求更高效的算

ACMer_quack&cheer 1054

不平衡电网下自抗扰顺序模型预测PWM整流器控制仿真模型(Simulink仿真实现)

内容概要:本文围绕面向城市空中交通的多无人机路径规划问题展开研究,提出了一套融合全局规划、动态避障与局部协同调整的综合路径规划方法。研究内容涵盖基于改进RRT算法与图论的全局路径规划、基于动态风险场和动态窗口法(DWA)的模型预测控制实现动态避障,以及基于分布式协同控制的多无人机局部路径协同策略。通过Matlab平台构建仿真环境,在多种典型城市交通场景下对所提方法进行了系统性验证,结果表明该方法在路径安全性、编队稳定性与任务效率方面表现优异。文章还深入探讨了算法的创新点与未来研究方向,为复杂城市环境下多无人机系统的自主协同提供了理论支撑与技术路径。; 适合人群:具备自动化、控制理论、计算机科学或相关领域基础知识,从事无人机系统、智能交通、路径规划、多智能体协同控制等方向研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①为城市空中交通系统中的多无人机安全、高效飞行提供可靠的路径规划解决方案;②支持在复杂、动态的城市场景中开展无人机自主导航、编队飞行与协同控制的技术研究与仿真验证。; 阅读建议:建议结合提供的Matlab代码进行实践操作,重点关注算法的具体实现细节、参数配置对性能的影响以及不同仿真场景下的实验设计,以深入理解各模块的集成逻辑与实际应用效果。

sgu183:Painting the balls(dp+优化)

题意: 在n(n 分析: 这个dp有点难想... 由于每次涂色的时候只与前两个涂色的球有关,因此设f[i][j]为倒数第二个涂色的为第i个球,最后一个涂色的球为第j个球的最小代价。 f[i][j]=min{f[k][i]}+c[j],由于区间[j-m,j-1]需要被覆盖,所以j-m 时间复杂度为O(n*m*m),话说应该过不了的,但竟然218ms过了.../* f[i][j]=min{

qq_20118433的专栏 1244

Python连接StarRocks全流程实践: SQL文件调用与Pandas混合优化

通过这种分阶段混合计算, 既能发挥StarRocks处理海量数据的性能优势, 又能保留Pandas在内存计算中的灵活性, 实现效率与功能的完美平衡.结合SQL的高效聚合与Pandas的灵活计算, 实现查询和数据处理的深度融合.该库基于SQLAlchemy 2.x开发, 仅支持Python 3.x环境.对大批量数据的写入, 建议进行分块. 分块写入较单条插入速度会有显著提升.这样可以避免python代码的查询与SQL耦合, 支持版本化管理.将DDL, DML分离为独立文件, 例如。: 调整连接复用参数。

t.y.Tang的博客 2780

卡诺图化简法注意事项+竞争冒险知识点总结

今天反思以下卡诺图化简法中的注意事项。 卡诺图看起来简单,但如果不熟悉的话很容易出错,因此要对画圈的规则比较熟悉。

weixin_42415266的博客 1万+

SGU 183 Painting the balls (DP优化)

183. Painting the balls time limit per test: 0.25 sec.  memory limit per test: 4096 KB input: standard input  output: standard output Petya puts the N white balls in a line and now

HIT_Foodie 1270

MaxEnt运行报错的各种问题及解决方法

由于我使用的环境数据并不是大部分人常用的worldclim上下载的气候数据,而是使用不同的四类环境数据,分别包括:降雨数据、气温数据、氮沉降数据和大气CO2浓度数据,数据需要分别从不同的网站下载,因此并不能得到非常一致的数据文件,导致MaxEnt运行时出现了各种各样的错误。文件终于能够读取了,然而计算到一半又弹出第三种问题,根据弹出的报错提示,找到错误所在那一行,用Notepad++打开,可以发现,这一行确实存在nan值,导致文件读取无法正常进行。出现上图所述的问题时,检查环境变量是否具有相同的行列号。

guye322的博客 1万+

Painting the balls (dp优化)

一种新的 \(dp\) 优化方法 设 \(f[i][j]\) 表示涂到第 \(i\) 个球,涂了 \(i\) 和 \(j\) 的最小代价 首先能够想出一种朴素的转移方程: \(f[i][j]=min(f[j][k])+c[j]~(k>i+1-m)\) 这样是 \(O(nm^2)\) 的,我们尝试去优化 对于 \(j,i~\in~\{j+1,j+m-1\},k~\in~\{i+1-m...

weixin_30410119的博客 283

OpenSees入门指南:从零开始的环境配置与TCL脚本实战

本文提供了一份详细的OpenSees入门指南,涵盖从零开始的环境配置到TCL脚本实战的全过程。文章重点讲解了OpenSees的安装步骤、环境变量设置,并推荐了高效的VS Code集成开发环境配置方法。通过一个简支梁分析的完整TCL脚本示例,手把手引导读者完成第一个非线性有限元分析,帮助土木工程与结构工程领域的研究者与学生快速上手这一强大的开源分析工具。

weixin_28829339的博客 336

保姆级教程:用Python+OpenCV实现相移法与格雷码三维重建(从生成条纹到点云生成)

本文详细介绍了使用Python和OpenCV实现相移法与格雷码三维重建的全流程,从条纹生成到点云计算。通过结构光技术,结合相移法和格雷码,实现高精度的三维重建,适用于无纹理物体表面的密集对应点生成。教程包含环境搭建、条纹生成、相位计算、三维点云重建及常见问题排查,适合计算机视觉开发者和研究人员。

weixin_33443333的博客 349

SGU 183 Painting the balls(DP)

题目链接:http://acm.sgu.ru/problem.php?contest=0&amp;problem=183 题意:一行方格,将第i个染色的代价是ci。将其中一些染色,使得任意连续的K个中至少有2个被染色。求最小代价。 思路:f[i][j]表示第i个第j个染色的最小代价。 #include &lt;iostream&gt; #include &lt;cstdio&gt; ...

weixin_33826609的博客 267

MaaS 商业模式全面分析报告:从技术赋能到商业变现的全链条探索

MaaS(模型即服务)商业模式正成为AI产业主流,2024年上半年中国市场规模达2.5亿元,预计2027年占比将提升至47%。该模式通过云服务提供预训练AI模型,大幅降低企业应用AI的技术门槛和成本。核心盈利方式包括按使用量计费、订阅制、定制化服务等,其中混合模式因灵活性成为趋势。MaaS产业链包含模型提供商、云平台、应用开发商和最终用户,重塑了AI产业格局。随着《数据法案》等监管加强,数据增值服务面临更严格合规要求。未来五年,中国MaaS市场增速预计超50%,用户规模将从2025年2.1亿增至2030年5

芯片行业20年 · 参与定义实现千万级量产出货 · AI芯片PM 2888

SGU 183. Painting the balls( dp )

dp..dp(i, j)表示画两个点为i-j, i的最优答案. dp(i, j) = min{ dp(i-j, k) } + cost[i] (1≤k≤M-j)令f(i, j) = min{dp(i, j)}, 那么转移时间下降为O(1).然后滚动数组..这道题卡空间..时间复杂度O(NM)-----------------------------------------------------...

weixin_30839881的博客 148

易语言游戏Call调用避坑指南:主线程绑定与反检测实战

本文详细解析了易语言游戏Call调用中的主线程绑定与反检测技术,帮助开发者避免游戏崩溃和断线问题。通过分析线程检测原理、提供易语言实现方案及高级反检测技巧,如动态线程绑定和上下文伪装,确保Call调用的稳定性和安全性。文章还包含常见问题排查和性能优化建议,适用于游戏辅助开发领域。

weixin_29323365的博客 458

Abaqus仿真进阶:如何准确计算气动软体机器人的抓取力(Blocking Force分析)

本文详细介绍了使用Abaqus进行气动软体机器人抓取力(Blocking Force)分析的进阶技巧。从材料模型验证、刚性目标物选择到接触对建立和充气加载优化,提供了一套完整的有限元仿真解决方案,帮助工程师准确预测软体执行器的抓取性能。

weixin_42528902的博客 401

[SGU 183] Painting the balls

一、题目 来源不详,好像是个外国网站。 peterpeterpeter 把 nnn 个白球排成一列,他想把一些白球刷为黑色,且任意连续 mmm 个球中至少要有 222 个黑球,peterpeterpeter 知道他需要 CiC_iCi​ 的燃料刷第 iii个球,你的任务是找出 peterpeterpeter 所需的最少的燃料达到目标。 2≤n≤104,2≤m≤100,m≤n2\leq n\leq10^4,2\leq m\leq 100,m\leq n2≤n≤104,2≤m≤100,m≤n 二、解法 数据范围

C202044zxy的博客 717

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

SGU 183 Painting the balls

题目描述 小宝把\(N\)个白球排成一列,他想把一些白球刷为黑色,且任意连续\(m\)个球中至少要有\(2\)个黑球。 小宝知道他需要\(C_i\)的染料刷第\(i\)个球。请你帮小宝算算他最少需要多少染料。 Input 第一行两个整数\(n\)和\(m\)。 第二行\(n\)个整数,表示\(C_i\) 。 对于\(30\%\)的数据\(n\)的数据范围\([1,20]\) 对于\(60...

341

温度PID控制PLC程序

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

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Painting the balls SGU - 183

定义 dp[i][j] 表示最后一个在位置i 倒数第二个在j时候的代价 这个复杂度是O(n*m*m)的 所以需要优化转移的时候是枚举ijk 三个点 优化实际上就是固定了中间那个点j 移动最后面的点i 往前移动i的同时用f[j][i-m]更新最小值 同时这个最小值也能更新新的f[i][j]优化后的复杂度为O(n*m)#include <iostream> #include <algorit

sb的博客 559

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

sgu 183. Painting the balls 动态规划 难度:3

183. Painting the balls time limit per test: 0.25 sec.memory limit per test: 4096 KB input: standard inputoutput: standard output Petya puts the N white balls in a line and now he wants to ...

weixin_30369087的博客 188

SCU 3037 Painting The Ball 详解

Painting The Balls 解题报告 题面: Petya puts the N white balls in a line and now he wants to paint some of them in black, so that at least two black balls could be found among any M successive balls. P...

Cleara8812的博客 283

sgu 183

动态规划开始不会做, 看了Owaski的题解才会的

Dash 719

sgu 183 分类: sgu 2015-03...

动态规划 开始不会做, 看了Owaski的题解才会的 #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<ctime> #include<iostream> #include&...

aa288288的博客 230

从零训练到上线:三个LLM的完整实践与避坑指南

大语言模型(LLM)的训练历来被看作高门槛工程,但从零训练并非只能依赖大规模GPU集群。通过理解数据清洗、tokenizer切分、损失函数与反向传播的基本原理,开发者完全可以在有限资源下展开有意义的实验。训练过程的真正价值不仅是获得一条下降的loss曲线,更在于建立可对比的评估方法——对照不同参数规模或数据量的模型表现,验证模型容量与数据规模的影响。同样关键的是把权重转化为可用服务:限制输入输出长度、设置超时、部署到公开页面接受真实用户输入,才能补齐从模型到产品闭环。本文围绕训练三个LLM并上线的完整过程,

weixin_34055787的博客 426

SCU3037 Painting the Balls

Description Petya puts the \(N\) white balls in a line and now he wants to paint some of them in black, so that at least two black balls could be found among any \(M\) successive balls. Petya kn...

weixin_30483013的博客 197
上一篇: HDU 3555Bomb数位dp
下一篇: hdu1874 Dijkstra(堆优化)+floyd
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值