hdu 2152 fire

算法七:道路升级 问题描述Z国有 n 个城市和 m 条双向道路,每条道路连接了两个不同的城市,保证所有城市之间都可以通过这些道路互达。每条道路都有一个载重量限制,这限制了通过这条道路的货车最大的载重量。道路的编号从 1 至 m 。巧合的是,所有道路的载重量限制恰好都与其编号相同。现在,要挑选出若干条道路,将它们升级成高速公路,并满足如下要求:所有城市之间都可以通过高速公路互达。对于任意两个城市 u,v 和足够聪明的... 阅读详情
/*
题目链接:http://poj.org/problem?id=2152

  题意:城市树形分布,每个城市修建消防站的有一个花费值cost,且,当该地着火,离他最近的那个消防站必须小于
  need,问要保证每个地方都能得到安全防护,需要的最小花费为?
 
    解题思路:令dp[i][j]为,保护i点的消防站修建在j点且以i为根节点,所有孩子即自己都能得到保护的的最小花费
    状态转移方程:dp[i][j]=w[j]+sum(min(dp[child][j]-w[j],best[child]));
    
      转载:
      
        非常非常好的一道树状DP!
        问题描述:
        Z国有n个城市,从1到n给这些城市编号。城市之间连着高速公路,并且每两个城市之间有且只有一条通路。不同的高速公路可能有不同的长度。最近Z国经常发生火灾,所以当地政府决定在某些城市修建一些消防站。在城市k修建一个消防站须要花费大小为的费用。函数W对于不同的城市可能有不同的取值。如果在城市k没有消防站,那么它到离它最近的消防站的距离不能超过。每个城市在不超过距离的前提下,必须选择最近的消防站作为负责站。函数D对于不同的城市可能有不同的取值。为了节省钱,当地政府希望你用最少的总费用修建一些消防站,并且使得这些消防站满足上述的要求。
        设:
        f[i][j]:表示以i为根的子树里修建一些消防站,并在节点j处修建一消防站,i的负责站必须是j
        best[i]:表示以i为根的子树的所有节点都有负责站的最小花费
        dist[i]表示i到x的距离,所以没换一个节点,都要再求一次dist[]。
        好了下面说下转移方程:
        首先选定一个节点(x)为根 ,遍历所有节点
        如果d[x]<dist[i],则i点不可能成为x的负责站f[x][i]=INF;
        如果d[x]>=dist[i],则i可以成为x的负责站,分三种情况讨论:(y是x的儿子)
        A.
        当i在以x为根的子树外时,对于x的每个儿子y都有两种选择:选择以y为根的子树内或外的消防站为负责站。当选择以y为根的子树内的消防站为负责站时,其子树所需的最少费用为best[y],当选择以y为根的子树外的消防站为负责站时,y只可以选择i上的消防站作为负责站,此时其子树所需的最少费用为f[k][i]。综上得到
        f[x][i]+=min(best[y],f[y][i]);
        (其实这块是反过来想的,当i点在x为根的子树外时,如果的x的儿子y选择i作为负责站,那么在i节点与y节点中间的x就一定是选择i了。)
        B.
        当x==i时,x的每个儿子的选择情况与A中的一样。此时还要加上修建x上的消防站的费用。因此
        f[x][i]+=w[x]+min(best[y],f[y][i]);
        C.
        当x!=i并且i在以x为根的子树内时,此时i必定在x的某个儿子y的子树里。对于x的每个不是y的儿子其选择情况与⑴中的一样,而对于y,它只能选择j作为负责站。综上得到
        f[x][i]+=f[y][i]+min(best[k],f[k][i]);(k是x中不是y的所有儿子)
*/
#include<stdio.h>
#include<string.h>
#define MAXN 1005
#define MAXE 2005
#define INF 100000000
#define min(a,b) ((a<b)?a:b)
int head[MAXN],cost[MAXN],need[MAXN],dis[MAXN];
struct Edge{
    int node;
    int next;
    int len;
}edge[MAXE];
int cnt,N;
int dp[MAXN][MAXN],ans[MAXN];
void add(int a,int b,int c)
{
    edge[cnt].len=c;edge[cnt].next=head[a];edge[cnt].node=b;head[a]=cnt++;
    edge[cnt].len=c;edge[cnt].next=head[b];edge[cnt].node=a;head[b]=cnt++;
}
void dfs(int fa,int root,int sum)
{
    int i;
    dis[root]=sum;
    for(i=head[root];~i;i=edge[i].next)
        if(edge[i].node!=fa)
            dfs(root,edge[i].node,sum+edge[i].len);    
}
void DP(int fa,int root)
{
    int i,j;
    for(i=head[root];~i;i=edge[i].next)
    {
        if(edge[i].node!=fa)
            DP(root,edge[i].node);    
    }
    dfs(-1,root,0);
    ans[root]=INF;
    for(i=1;i<=N;i++)
    {
        if(dis[i]<=need[root])
        {
            dp[root][i]=cost[i];
            for(j=head[root];~j;j=edge[j].next)
            {
                if(edge[j].node!=fa)
                {
                    dp[root][i]+=min(ans[edge[j].node],dp[edge[j].node][i]-cost[i]);
                }
            }
            if(dp[root][i]<ans[root])ans[root]=dp[root][i];
        }
        else
            dp[root][i]=INF;
    }
}
int main()
{
    int T,i,a,b,c;
    //    freopen("in.txt","r",stdin);
    for(scanf("%d",&T);T--;)
    {
        scanf("%d",&N);
        for(i=1;i<=N;i++)scanf("%d",&cost[i]);
        for(i=1;i<=N;i++)scanf("%d",&need[i]);
        
        memset(head,-1,sizeof(head));
        for(i=1,cnt=0;i<N;i++)
        {
            scanf("%d%d%d",&a,&b,&c);
            add(a,b,c);
        }
        DP(-1,1);
        printf("%d\n",ans[1]);
    }
    return 0;
}

/*
10
5
1 1 1 1 1
1 1 1 1 1
1 2 1
2 3 1
3 4 1
4 5 1
5
1 1 1 1 1
2 1 1 1 2
1 2 1
2 3 1
3 4 1
4 5 1
5
1 1 3 1 1
2 1 1 1 2
1 2 1
2 3 1
3 4 1
4 5 1
4
2 1 1 1
3 4 3 2
1 2 3
1 3 3
1 4 2
4
4 1 1 1
3 4 3 2
1 2 3
1 3 3
1 4 2

*/


手把手教你用Apollo Dreamview调试自动驾驶感知模块(附数据包下载) 本文详细介绍了如何使用百度Apollo平台的Dreamview工具调试自动驾驶感知模块,包括环境配置、数据加载、感知问题定位和多传感器融合调试等关键步骤。通过实战案例和参数调整技巧,帮助开发者快速掌握自动驾驶感知模块的调试方法,提升开发效率。 阅读详情

相关推荐

vuecil3+版本下,兼容ie等不支持es6的低版本浏览器

*综上,完成兼容性涉及到的配置的文件有,对应在页面中查看代码,就不单独附代码了:main.js。

yhr0322的博客 833

POJ 2152 树型DP //很棒的题

题意:Z国有n个城市,从1到n给这些城市编号。城市之间连着高速公路,并且每两个城市之间有且只有一条通路。不同的高速公路可能有不同的长度。最近Z国经常发生火灾,所以当地政府决定在某些城市修建一些消防站。在城市k修建一个消防站须要花费大小为W[k]的费用。函数W对于不同的城市可能有不同的取值。如果在城市k没有消防站,那么它到离它最近的消防站的距离不能超过D[k]。每个城市在不超过距离D[k]的前提下,必

Sky 835

信捷CODESYS平台伺服电机转矩控制模式应用与切换

信捷CODESYS二次开发软件:XS Studio 在运动控制中的转矩控制案例

weixin_64614866的博客 1万+

poj 2152 Fire 树形DP

树形DP

NeighThorn的博客 622

用Arduino+ESP32复现TDOA定位:低成本实现厘米级精度的完整教程

本文提供了一套利用Arduino和ESP32平台,结合NRF24L01+模块与GPS/PPS时间同步方案,低成本复现高精度TDOA(到达时间差)定位系统的完整教程。教程详细阐述了从硬件选型、天线阵列设计、时间同步实现到核心算法与多径抑制的实战步骤,旨在帮助开发者和硬件爱好者以可控成本实现厘米级精度的定位演示系统。

weixin_29084111的博客 162

Windows 10/11 下用 Docker 一键部署 CVAT 标注工具(附 WSL2 配置指南)

本文详细指导如何在Windows 10/11系统上,通过配置WSL2和Docker Desktop,实现CVAT标注工具的一键部署。内容涵盖从环境准备、Docker安装、CVAT服务启动到性能优化与安全配置的全流程,为计算机视觉开发者提供稳定高效的本地标注平台解决方案。

weixin_28839601的博客 463

POJ2152 Fire

描述: Z国有N个城市,编号为从1到N。城市之间用高速公路连接,并且每两个城市之间都有唯一一条路径。最近Z国经常发生火灾,所以政府决定在一些城市修建消防站。在城市K建立消防站要花费W(K)。不同的城市花费不同。如果在城市K没有消防站,则离他最近的消防站与他的距离不能超过D(K),不同城市的D也不相同。为了省钱,政府希望你能算出修建消防站最小的总花费。 输入: 第一行输入包含一个整数T,表示有

Programing_Excalibur的博客 1371

oracle19c 无备份情况下重建ocr 和 votedisk

无备份情况下重建ocr 和 votedisk – 19c 备注:测试环境基本上都有ocr自动备份文件,建议参考有备份情况下恢复ocr和votedisk Deconfigure and reconfigure entire cluster will rebuild OCR and Voting Disk, user resources (database, instance, service, ...

fangang001的专栏 4179

虚拟城市之旅(强连通+搜索)Tarjan

<br />题目描述:<br /> 展馆是未来城市的缩影,个人体验和互动是不变的主题。在A国展馆通过多维模式和高科技手段,引领参观者在展示空间踏上一段虚拟的城市之旅。梦幻国有N个城市和M条道路,每条道路连接某两个城市。任意两个城市之间最多只有一条道路直接相连。这M条道路中有一部分为单向通行的道路,一部分为双向通行的道路。梦幻国幅员辽阔,各地的资源分布情况各不相同,这就导致了同一种商品在不同城市的价格不一定相同。但是,同一种商品在同一个城市的买入价和卖出价始终是相同的。现在你已踏上一段虚拟的城市之旅。为了给你

dooder_daodao的专栏 974

TB6600驱动器共阴共阳接法傻傻分不清?一张图搞定STM32与42步进电机的接线避坑指南

本文详细解析了TB6600驱动器共阴共阳接法的本质区别,提供了STM32与42步进电机的高效连接方案。通过实际案例和接线图示,帮助读者避免常见错误,确保驱动器与MCU的安全连接,提升项目稳定性。

weixin_28710999的博客 245

[全志T113]:ST7701 86屏幕驱动

[全志T113]:ST7701 86屏幕驱动

LINKKEEE的博客 3141

Hdu4582-DFS spanning tree VS Pku2152-Fire 一类平方级树形最小覆盖问题

/* 题意:某国N个城市,之间树形交通网络。现要在一些城市建消防站,要求:每个城市i要 么有自己的消费站,要么离最近的有消费站的城市的距离不超过Di(各个城市的要求 不尽相同)。同时,各城市建消防站的费用Wi已知,也不尽相同。 解法:树形动态规划。想到用DP来解题不难,难的是想出怎么来DP。对于状态的设计,我们 大概能猜到这个应该用的是二维的状态,其中一维表示D

Wo xi Meiz 1466

innovus:Patch Wire(补丁线)

1)选中wire ,shift+A使用Edit Route功能,F3打开edit route对话框。线道Create Patch Wire,设置好层次和宽度。在修补一些min area的drc时,会有一些danling wire的drc冒出来,为了避免这些假错,可以使用工具patch wire功能。2)沿着选中的wire画线即可。如下图,patch wire和regular wire是能看出区别的。我正在「拾陆楼」和朋友们讨论有趣的话题,你⼀起来吧?

m0_61544122的博客 1963

P1462 通往奥格瑞玛的道路

题目链接 题意:大概就是,有一个人需要从1城市走到n城市,路途中每经过一个城市都要交钱(包括1城市和n城市),从一个城市走到另一个城市的道路中会被扣除ci的血量,他总共有b的血量。求所有可能的路线当中,路线中包含城市(单座)费用最大值;再把这些最大值作比较取最小值输出。 代码如下: #include <bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define Maxn 10005 #define Maxm 100010

b_b_lai_lai的博客 353

温度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")

复赛模拟试题 - 收费站 Dijkstra迪杰斯特拉+二分答案法 重庆一中高2018级竞赛班第九次测试 2016.9.10 Problem 4

【问题描述】 在某个遥远的国家里,有n个城市。编号为1 ,2,3,…,n。这个国家的政府修建了m条双向的公路。每条公路连接着两个城市。沿着某条公路,开车从一个城市到另一个城市,需要花费一定的汽油。开车每经过一个城市,都会被收取一定的费用(包括起点和终点城市)。所有的收费站都在城市中,在城市间的公路上没有任何的收费站。小红现在要开车从城市u到城市v(1<=u,v<=n)。她的车最多可以装下s升的汽油

灬豪侠彡 897

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

20150807训练题

by 金大师 【T1】路径 (way.pas/c/cpp) 3s  512MB 【问题描述】 A国有n个城市,编号为1到n,任意两个城市之间有一条路。shlw闲得没事干想周游A国,及从城市1出发,经过且仅经过除城市1外的每个城市1次(城市1两次),最后回到城市1。由于shlw很傻,他只愿意走一定长度,多了少了都不干,现在他想知道一共有多少种方案可供选择。 【输入】 输入文件名为way

Johann的博客 2417

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

poj Tony’s Tour (插头DP处女作--楼教主男(难)人八题之一)

/* //题目链接:http://poj.org/problem?id=1739 acm记忆:在很久很久以前 ,当插头DP还只是被称作“基于连通性状态压缩动态规划”的时候,楼教主就将其化为男人八题 之列 !引得无数自认为很man的英雄豪杰欲AC之 而后快 !而吾等菜鸟是这学期才听闻 到还有插头DP一说 ,故欲快速刷之以解心中愁!遂捧着cdq(性别 :女)关于基于连通性状态压缩动态规划的

SprintfWater的专栏 4904

hdu 4512 吉哥系列故事——完美队形I(最长上升公共子串)

求最长上升公共子串 f【i】【j】表示a(1,i),b(1,j)取以b【j】结尾的最大公共上升子串的大小 当a【i】 != b【j】 时,f【i】【j】 = f【i - 1】【j】 否则:f【i】【j】 = max { f【i - 1】【(1……j - 1)】 && (a[i] > b[1……j - 1])}; #include #include #include #define

SprintfWater的专栏 2681

hdu 4504威威猫系列故事——篮球梦

第五题:整数划分 dp[m] += dp[m - i](i = 1,2,3) #include #include #include #include using namespace std; #define INF 100000000 #define MAXN 200

SprintfWater的专栏 1955

hdu 4044 GeoDefense

//该题链接http://acm.hdu.edu.cn/showproblem.php?pid=4044 /* 报告人:SpringWater(GHQ)   //此题大意:一个以1为根节点的树,每个节点可以有修防御系统,每个节点的   防御系统(具有不同的价格和防御力)有chioce种可能的选择,敌人的基地为根节点,我方的基地为所有的叶   子节点,敌人可以随机发射一个攻击(具有一定的

SprintfWater的专栏 1914

成都区域赛区Maze杭电4035(dp求期望)

解题思路分析过程转载 : 02.    dp求期望的题。 03.    题意: 04.    有n个房间,由n-1条隧道连通起来,实际上就形成了一棵树, 05.    从结点1出发,开始走,在每个结点i都有3种可能: 06.        1.被杀死,回到结点1处(概率为ki) 07.        2.找到出口,走出迷宫 (概率为ei) 08.        3.和

SprintfWater的专栏 1811

hdu 4405 Aeroplane chess(很水的期望DP)

题目大意:通过摇筛子,做0跳到n点,有些点可以直接过渡,问要到达n点,需要摇色子的次数的期望值? 状态转移方程: 首先dp【N】=0; 其次分两种情况: (1)i点不可以过渡,dp【i】=sum((dp【i+j】+1)/6) (2)i点可以过渡到j点,dp【i】=dp[j] 代码如下: #include #include #define MAXN 100005 int

SprintfWater的专栏 1591

hdu 4258(斜率优化DP)

题目大意:将n个升序数字序列,分成几组连续的序列 ,每一组的所得值,等于最右边的num2减去最左边 的num1,的平方+c即(numi-numj)^2+c 解题报告 人:GHQ(SpringWater) 分析可得:(dp[j2]-dp[j1]+num[j2+1]*num[j2+1]-num[j1+1]*num[j1+1])/(2(num[j2+1]-num[j1+1]))《=num[i

SprintfWater的专栏 1507

hdu 4519 郑厂长系列故事——体检(贪心)

比赛的时候,尼吗忘了N《=M的那种情况,害我wa了一次,忏悔! 见代码一目了然: #include #include int main() { int T, N, K, M; for(scanf("%d", &T); T--;) { scanf("%d%d%d", &N, &K, &M); if(N <= M) printf("%d\n", K); else printf("%d\n"

SprintfWater的专栏 1368

区间DP(可以看成记忆化搜索)

最少步 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submission(s) : 22   Accepted Submission(s) : 4 Font: Times New Roman | Verdana | Georgia Font Size: ←

SprintfWater的专栏 1357

hdu 4412 Sky Soldiers(区间DP)

题目问题抽象之后为:在一个x坐标轴上有N个点,每个点上有一个概率值,可以修M个工作站,                      求怎样安排这M个工作站的位置,使得这N个点都走到工作站的距离期望值最小? 解题报告人:SpringWater(GHQ) 解题思路:状态方程:dp[i][j]  =  min{ dp[i - 1][k - 1]  + cost[k][j]   }dp[i][

SprintfWater的专栏 1206
上一篇: hdu 2167 Pebbles(状态压缩)
下一篇: zju Back to the Past 4624
SprintfWater
博客等级 码龄15年 242粉丝 139原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值