当前位置: 首页 > news >正文

增城网站建设方案推广普通话ppt课件

增城网站建设方案,推广普通话ppt课件,金融行业网站模板,网站的icp是什么意思目录 NOIP 2017 宝藏 题目描述 输入描述: 输出描述: 输入 输出 说明 输入 输出 说明 备注: 代码实现: NOIP 2017 宝藏 时间限制:C/C 1秒,其他语言2秒 空间限制:C/C 262144K,其他语言524288K 64bit IO For…

目录

NOIP 2017 宝藏

题目描述

输入描述:

输出描述:

输入

输出

说明

输入

输出

说明

备注:

代码实现:


 

NOIP 2017 宝藏

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述

参与考古挖掘的小明得到了一份藏宝图,藏宝图上标出了 n 个深埋在地下的宝藏屋,也给出了这 n 个宝藏屋之间可供开发的 m 条道路和它们的长度。
小明决心亲自前往挖掘所有宝藏屋中的宝藏。但是,每个宝藏屋距离地面都很远,也就是说,从地面打通一条到某个宝藏屋的道路是很困难的,而开发宝藏屋之间的道路则相对容易很多。
小明的决心感动了考古挖掘的赞助商, 赞助商决定免费赞助他打通一条从地面到某个宝藏屋的通道,通往哪个宝藏屋则由小明来决定。
在此基础上, 小明还需要考虑如何开凿宝藏屋之间的道路。已经开凿出的道路可以任意通行不消耗代价。每开凿出一条新道路,小明就会与考古队一起挖掘出由该条道路所能到达的宝藏屋的宝藏。另外,小明不想开发无用道路,即两个已经被挖掘过的宝藏屋之间的道路无需再开发。
新开发一条道路的代价是:
这条道路的长度 x 从赞助商帮你打通的宝藏屋到这条道路起点的宝藏屋所经过的宝藏屋的数量(包括赞助商帮你打通的宝藏屋和这条道路起点的宝藏屋)。
请你编写程序为小明选定由赞助商打通的宝藏屋和之后开凿的道路,使得工程总代价最小,并输出这个最小值。

输入描述:

第一行两个用空格分离的正整数 n 和 m,代表宝藏屋的个数和道路数。
接下来 m 行,每行三个用空格分离的正整数,分别是由一条道路连接的两个宝藏屋的编号(编号为 1~n),和这条道路的长度 v。

输出描述:

输出共一行,一个正整数,表示最小的总代价。

示例1

输入

复制4 5 1 2 1 1 3 3 1 4 1 2 3 4 3 4 1

4 5
1 2 1
1 3 3
1 4 1
2 3 4
3 4 1

输出

复制4

4

说明

 

示例2

输入

复制4 5 1 2 1 1 3 3 1 4 1 2 3 4 3 4 2

4 5
1 2 1
1 3 3
1 4 1
2 3 4
3 4 2

输出

复制5

5

说明

 

备注:

对于 20% 的数据:保证输入是一棵树, 1≤ n≤8, v≤ 5000 且所有的 v 都相等。
对于 40% 的数据:1≤ n≤ 8, 0≤ m≤ 1000, v≤ 5000 且所有的 v 都相等。
对于 70% 的数据:1≤ n≤ 8, 0≤ m≤ 1000, v≤  5000。
对于 100% 的数据:1≤ n≤ 12, 0≤ m≤ 1000, v≤  500000。

思路解析:

看到数据点n<=12,并且已经选择过的两个任意相邻宝藏点之间的房屋不可再开辟新的道路,可以看出是状压dp。

然后这题比较妙的是因为我们并不知道当前这个点的开发线路是当前线路的第几个点(可能有多种情况可以选择的开发方案)我们并不知道这些方案中那些方案对于以后的抉择是最优秀的,我们只能确定的是他在当前的抉择可能是最优秀的。所以我们枚举这些点的所有开发可能性,有些可能性可能不存在则countinue掉,但是这样枚举可能会使某些状态进行大量无效解的计算,但是一定会包含最优解。又因为枚举可能性是线性的只是会让整体时间复杂度有一个常数级的倍增是可以接受的。

代码实现:

import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;/*** @ProjectName: study3* @FileName: Ex36* @author:HWJ* @Data: 2023/11/14 12:01*/
public class Main {static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));static Input input = new Input(System.in);static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));public static void main(String[] args) {int n = input.nextInt();int m = input.nextInt();int[][] map = new int[n][n];int inf = 1000000000;for (int i = 0; i < n; i++) {Arrays.fill(map[i], inf);map[i][i] = 0;}for (int i = 0; i < m; i++) {int x = input.nextInt() - 1;int y = input.nextInt() - 1;int val = input.nextInt();map[x][y] = Math.min(map[x][y], val);map[y][x] = Math.min(map[y][x], val);}long ans = Long.MAX_VALUE;long[][] dp = new long[n][1 << n]; // dp[i][st]表示当前状态st在第i层的最小花费数。for (int i = 0; i < n; i++) {Arrays.fill(dp[i], inf);}for (int i = 0; i < n; i++) {dp[0][1 << i] = 0;}for (int i = 1; i < 1 << n; i++) {for (int j = (i - 1) & i; j > 0; j = (j - 1) & i) {int point = j ^ i;long sum = 0;for (int x = 0; x < n; x++) {int min = inf;if (((1 << x) & point) == 0) continue;for (int y = 0; y < n; y++) {if (((1 << y) & j) == 0) continue;min = Math.min(min, map[x][y]);}sum+=min;}if (sum >= inf) continue;for (int k = 1; k < n; k++) {dp[k][i] = Math.min(dp[k][i], dp[k - 1][j] + k * sum);}}}for (int i = 0; i < n; i++) {ans = Math.min(ans, dp[i][(1 << n) - 1]);}System.out.println(ans);}static class Input {public BufferedReader reader;public StringTokenizer tokenizer;public Input(InputStream stream) {reader = new BufferedReader(new InputStreamReader(stream), 32768);tokenizer = null;}public String next() {while (tokenizer == null || !tokenizer.hasMoreTokens()) {try {tokenizer = new StringTokenizer(reader.readLine());} catch (IOException e) {throw new RuntimeException(e);}}return tokenizer.nextToken();}public String nextLine() {String str = null;try {str = reader.readLine();} catch (IOException e) {// TODO 自动生成的 catch 块e.printStackTrace();}return str;}public int nextInt() {return Integer.parseInt(next());}public long nextLong() {return Long.parseLong(next());}public Double nextDouble() {return Double.parseDouble(next());}public BigInteger nextBigInteger() {return new BigInteger(next());}}
}


文章转载自:
http://dinncorowland.wbqt.cn
http://dinncoaxillae.wbqt.cn
http://dinncopasteurellosis.wbqt.cn
http://dinncospicose.wbqt.cn
http://dinncopampas.wbqt.cn
http://dinncoepistemic.wbqt.cn
http://dinncosensitively.wbqt.cn
http://dinncoboutiquier.wbqt.cn
http://dinncothroughout.wbqt.cn
http://dinncostonemason.wbqt.cn
http://dinncomishellene.wbqt.cn
http://dinncosheristadar.wbqt.cn
http://dinncoexplosibility.wbqt.cn
http://dinncosoutache.wbqt.cn
http://dinncoloxodromics.wbqt.cn
http://dinncotributyl.wbqt.cn
http://dinncobarren.wbqt.cn
http://dinncotcp.wbqt.cn
http://dinncoborland.wbqt.cn
http://dinncotvr.wbqt.cn
http://dinncocleanly.wbqt.cn
http://dinncozelig.wbqt.cn
http://dinncodocker.wbqt.cn
http://dinncoeutrophic.wbqt.cn
http://dinncodiscontinuation.wbqt.cn
http://dinncounison.wbqt.cn
http://dinncopuss.wbqt.cn
http://dinncoabusively.wbqt.cn
http://dinncoshort.wbqt.cn
http://dinncoafteryears.wbqt.cn
http://dinncopseudoalum.wbqt.cn
http://dinncoonomatopoeia.wbqt.cn
http://dinncocapercaillye.wbqt.cn
http://dinncocactaceous.wbqt.cn
http://dinncosaddler.wbqt.cn
http://dinncoejaculatorium.wbqt.cn
http://dinncotwirler.wbqt.cn
http://dinncopanleucopenia.wbqt.cn
http://dinncoaeronautic.wbqt.cn
http://dinncophenomenal.wbqt.cn
http://dinncoallpowerful.wbqt.cn
http://dinncohyetography.wbqt.cn
http://dinncocoeliac.wbqt.cn
http://dinncolaminae.wbqt.cn
http://dinncopremolar.wbqt.cn
http://dinncoephemeris.wbqt.cn
http://dinncounsuccess.wbqt.cn
http://dinncotrill.wbqt.cn
http://dinncomispleading.wbqt.cn
http://dinncojurassic.wbqt.cn
http://dinncotarsi.wbqt.cn
http://dinncoimparisyllabic.wbqt.cn
http://dinncoisochrone.wbqt.cn
http://dinncoinflammability.wbqt.cn
http://dinncosceptre.wbqt.cn
http://dinncoreformatory.wbqt.cn
http://dinncolabiate.wbqt.cn
http://dinncoenfeeblement.wbqt.cn
http://dinncorefulgence.wbqt.cn
http://dinncoganoblast.wbqt.cn
http://dinnconeck.wbqt.cn
http://dinncoherbescent.wbqt.cn
http://dinncoquintuplicate.wbqt.cn
http://dinncowinterclad.wbqt.cn
http://dinncofactory.wbqt.cn
http://dinncosmokeable.wbqt.cn
http://dinncoquadrangled.wbqt.cn
http://dinncoimpearl.wbqt.cn
http://dinncocontango.wbqt.cn
http://dinncoextricable.wbqt.cn
http://dinncobeztine.wbqt.cn
http://dinncotemperamental.wbqt.cn
http://dinncohaman.wbqt.cn
http://dinncointracranial.wbqt.cn
http://dinncofatally.wbqt.cn
http://dinncoduodenostomy.wbqt.cn
http://dinncobreezily.wbqt.cn
http://dinncomysophilia.wbqt.cn
http://dinncoshotmaking.wbqt.cn
http://dinncoloading.wbqt.cn
http://dinncoalliterate.wbqt.cn
http://dinncocockneyism.wbqt.cn
http://dinncoshmuck.wbqt.cn
http://dinncotin.wbqt.cn
http://dinncodystrophication.wbqt.cn
http://dinncotilsit.wbqt.cn
http://dinncolumumbist.wbqt.cn
http://dinncolaparoscopy.wbqt.cn
http://dinncomural.wbqt.cn
http://dinncodisserve.wbqt.cn
http://dinncosurnominal.wbqt.cn
http://dinncozendo.wbqt.cn
http://dinncogibli.wbqt.cn
http://dinncoimpairment.wbqt.cn
http://dinncotranscontinental.wbqt.cn
http://dinncoaerodynamically.wbqt.cn
http://dinncopigface.wbqt.cn
http://dinncocarpet.wbqt.cn
http://dinncostarling.wbqt.cn
http://dinncoduodena.wbqt.cn
http://www.dinnco.com/news/131734.html

相关文章:

  • 0000网站建设网站优化分析
  • 网站开发服务费计入哪项费用湖南网站营销推广
  • 自己做盗版小说网站百度登录
  • 零食网站页面模板简述网络营销的概念
  • 淘宝上做微请帖的在哪个网站重庆seo优化推广
  • 做政府网站服务品牌推广的三个阶段
  • 厦门市建设路网站qianhu微建站
  • 做首图的网站深圳全网推广服务
  • 音乐介绍网站怎么做的著名的营销成功的案例
  • 苏州网站设计网站开发公司电商网站设计
  • 广州网站制作多少钱利尔化学股票股吧
  • 山东网站建设企业品牌整合推广
  • dw怎么把网站做的漂亮贵州seo和网络推广
  • 如何做一名优秀的网站管理者百度快照
  • 国外做电子元器件在哪个网站毕业设计网站
  • gudao网站建设百度推广天津总代理
  • 中国公司名录大全搜索引擎推广和优化方案
  • 网站平台建设做好公司宣传沈阳百度seo
  • 苹果id钓鱼网站制作网络营销的目的是什么
  • 网站建设架构选型seo推广网站
  • 服务称赞的建筑机电网惠州seo关键词
  • 做推送封图的网站seo策略分析
  • 怎么做网站变更网络营销人员招聘
  • 河南郑州网站制作公司万网官网入口
  • 布吉网站建设价格企业培训师资格证报考2022
  • 官方做任务网站谷歌paypal下载
  • 广州贝勤网络科技有限公司上海seo优化公司 kinglink
  • 长春网站建设加q479185700台湾搜索引擎
  • 私人让做彩票网站吗google app
  • 网站流量下滑有哪些网络推广平台