- 浏览: 36793 次
- 性别:
- 来自: 湖南
最新评论
-
kulinglei:
提烟而过 写道问下楼主:你是拿了别人的注册号在这里害别人,还是 ...
折半搜索 -
jy00105276:
没看代码,看描述难道是2分法?
是的话不一定是a[i-1] ...
折半搜索 -
提烟而过:
问下楼主:你是拿了别人的注册号在这里害别人,还是没事在这里装- ...
折半搜索 -
zqynux:
fffvvvzz 写道11-15
是
11 12 13 14 ...
折半搜索 -
zqynux:
额,, 就是一个NOIP题目的答案..
vijos 谁拿了最多奖学金
Agri-Net
Russ Cox
Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.
Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms.
Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm.
The distance between any two farms will not exceed 100,000.
PROGRAM NAME: agrinet
INPUT FORMAT
Line 1: The number of farms, N (3 <= N <= 100).
Line 2..end: The subsequent lines contain the N x N connectivity matrix, where each element shows the distance from on farm to another. Logically, they are N lines of N space-separated integers. Physically, they are limited in length to 80 characters, so some lines continue onto others. Of course, the diagonal will be 0, since the distance from farm i to itself is not interesting for this problem.
SAMPLE INPUT (file agrinet.in)
4
0 4 9 21
4 0 8 17
9 8 0 16
21 17 16 0
OUTPUT FORMAT
The single output contains the integer length that is the sum of the minimum length of fiber required to connect the entire set of farms.
SAMPLE OUTPUT (file agrinet.out)
28
描述
农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,并连接到所有的农场。当然,他需要你的帮助。约翰已经给他的农场安排了一条高速的网络线路,他想把这条线路共享给其他农场。为了使花费最少,他想铺设最短的光纤去连接所有的农场。你将得到一份各农场之间连接费用的列表,你必须找出能连接所有农场并所用光纤最短的方案。每两个农场间的距离不会超过100000
格式
PROGRAM NAME: agrinet
INPUT FORMAT:
(file agrinet.in)
第一行: 农场的个数,N(3<=N<=100)。
第二行..结尾: 后来的行包含了一个N*N的矩阵,表示每个农场之间的距离。理论上,他们是N行,每行由N个用空格分隔的数组成,实际上,他们限制在80个字符,因此,某些行会紧接着另一些行。当然,对角线将会是0,因为不会有线路从第i个农场到它本身。
OUTPUT FORMAT:
(file agrinet.out)
只有一个输出,其中包含连接到每个农场的光纤的最小长度。
SAMPLE INPUT
4
0 4 9 21
4 0 8 17
9 8 0 16
21 17 16 0
SAMPLE OUTPUT
28
======================= 华丽的分割线 =======================
这一题就是最小生成树的问题, 说来复杂... 自己看数据结构吧..
Russ Cox
Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.
Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms.
Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm.
The distance between any two farms will not exceed 100,000.
PROGRAM NAME: agrinet
INPUT FORMAT
Line 1: The number of farms, N (3 <= N <= 100).
Line 2..end: The subsequent lines contain the N x N connectivity matrix, where each element shows the distance from on farm to another. Logically, they are N lines of N space-separated integers. Physically, they are limited in length to 80 characters, so some lines continue onto others. Of course, the diagonal will be 0, since the distance from farm i to itself is not interesting for this problem.
SAMPLE INPUT (file agrinet.in)
4
0 4 9 21
4 0 8 17
9 8 0 16
21 17 16 0
OUTPUT FORMAT
The single output contains the integer length that is the sum of the minimum length of fiber required to connect the entire set of farms.
SAMPLE OUTPUT (file agrinet.out)
28
描述
农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,并连接到所有的农场。当然,他需要你的帮助。约翰已经给他的农场安排了一条高速的网络线路,他想把这条线路共享给其他农场。为了使花费最少,他想铺设最短的光纤去连接所有的农场。你将得到一份各农场之间连接费用的列表,你必须找出能连接所有农场并所用光纤最短的方案。每两个农场间的距离不会超过100000
格式
PROGRAM NAME: agrinet
INPUT FORMAT:
(file agrinet.in)
第一行: 农场的个数,N(3<=N<=100)。
第二行..结尾: 后来的行包含了一个N*N的矩阵,表示每个农场之间的距离。理论上,他们是N行,每行由N个用空格分隔的数组成,实际上,他们限制在80个字符,因此,某些行会紧接着另一些行。当然,对角线将会是0,因为不会有线路从第i个农场到它本身。
OUTPUT FORMAT:
(file agrinet.out)
只有一个输出,其中包含连接到每个农场的光纤的最小长度。
SAMPLE INPUT
4
0 4 9 21
4 0 8 17
9 8 0 16
21 17 16 0
SAMPLE OUTPUT
28
======================= 华丽的分割线 =======================
这一题就是最小生成树的问题, 说来复杂... 自己看数据结构吧..
/* LANG: C ID: zqy11001 PROG: agrinet */ #include <stdio.h> #define getint(i) scanf("%d", &i) #define MAX 100 #define INF 1e6 int map[MAX][MAX]; int visited[MAX]; int path[MAX]; int main(void) { int n; int i, j, k; int min, m, tot = 0; freopen("agrinet.in", "r", stdin); freopen("agrinet.out", "w", stdout); getint(n); for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ getint(map[i][j]); } } for(i = 0; i < n; i++){ path[i] = map[0][i]; } visited[0] = 1; for(i = 1; i < n; i++){ min = INF; for(j = 0; j < n; j++){ if(!visited[j] && min > path[j]){ min = path[j]; m = j; } } visited[m] = 1; tot += min; for(j = 0; j < n; j++){ if(visited[j] == 0 && map[m][j] < path[j]){ path[j] = map[m][j]; } } } printf("%d\n", tot); return 0; }
发表评论
-
重做 USACO 1.1 黑色星期五
2010-03-31 18:59 1295/* LANG: C ID: zqynux11 PROG ... -
重做 USACO 1.1 黑色星期五
2010-03-31 18:59 841解释什么的就算了吧,, /* LANG: C ID: ... -
重做 USACO 1.1 贪婪的送礼者
2010-03-31 18:58 1252这题的话, 我用的是个结构体, 记录各个人.. 我错了的地 ... -
重做 USACO 1.1 你的飞碟在这儿
2010-03-31 18:56 888不解释了.. /* LANG: C ID: zqynu ... -
USACO 3.1 Shaping Regions 形成的区域
2010-03-30 20:01 1536这题二话不说, 用map[i][j]表示坐标为i, j的点 ... -
USACO 3.1 Humble Numbers 丑数
2010-03-28 15:31 1487从这一题开始,, 以后题目我就不贴上来了... 自己去看吧 ... -
USACO 3.1 Score Inflation 总分
2010-03-27 20:19 842Score Inflation The more point ... -
USACO 2.4 Fractions to Decimals 分数化小数
2010-03-27 15:47 1290Fractions to Decimals Write a ... -
USACO 2.4 Bessie Come Home 回家
2010-03-27 13:01 1030Bessie Come Home Kolstad & ... -
USACO 2.4 Cow Tours 牛的旅行
2010-03-27 11:57 1127Cow Tours Farmer John has a nu ... -
USACO 2.4 Overfencing 穿越栅栏
2010-03-25 18:18 966USACO 2.4 Overfencing 穿越栅栏 Over ... -
USACO 2.4 The Tamworth Two 两只塔姆沃斯牛
2010-03-23 22:05 1220The Tamworth Two BIO '98 - Rich ... -
USACO 2.3 Controlling Companies 控制公司
2010-03-23 22:00 1470Controlling Companies Some com ... -
USACO 1.1 Broken Necklace 破碎的项链
2010-03-22 18:04 2128Broken Necklace You have a neck ... -
USACO 2.3 Money Systems 货币系统
2010-03-22 13:31 985Money Systems The cows have no ... -
USACO 2.3 Cow Pedigrees 奶牛家谱
2010-03-21 15:02 1436Farmer John is considering purc ... -
USACO 2.3 Zero Sum 零的算式和
2010-03-20 14:30 1792Zero Sum Consider the sequence ... -
USACO Longest Prefix最长前缀
2010-03-17 12:28 1438Longest Prefix IOI'96 The stru ... -
vijos 谁拿了最多奖学金
2010-03-17 12:25 1104描述 Description 某校的惯例是在每 ... -
USACO 2.2 Subset Sums集合
2010-03-16 12:18 1475USACO 2.2 Subset Sums集合 For ...
相关推荐
【标签】"POJ 1258 Agri-Net Prim" 说明了这个题目的编号是POJ1258,题目背景可能是与农业网络(Agri-Net)相关的,而核心算法是Prim算法。Prim算法是一种在加权无向图中寻找最小生成树的算法,用于找到连接所有顶点...
pku acm 1258 Agri-Net代码 最小生成树的prim算法,有详细的注释
题目中提到的"最短网络"是指寻找最小生成树(Minimum Spanning Tree, MST),这是一个经典的图论问题。在解决这类问题时,可以使用Prim算法或Kruskal算法来寻找最小生成树。 Prim算法从一个顶点开始,逐步增加边,每次...
【标题】中的“1258:Agri-Net(弗洛伊德)”指的是一道编程竞赛题目,该题目可能要求解决图论中的最短路径问题,使用了弗洛伊德算法作为解决方案。 【描述】中提到的“弗洛伊德思路”是指弗洛伊德算法的基本思想。...
1. **物联网(IoT)基础**:物联网是互联网、传统电信网等信息承载体,让所有能行使独立功能的普通物体实现互联互通的网络。在农业领域,物联网技术可以用于监测环境条件,如温度、湿度、光照、土壤质量等。 2. **...
标题“POJ3414-Pots”是一个编程竞赛题目,源自北京大学的在线判题系统POJ(Problem Online Judge)。这个题目主要考察的是算法设计和实现能力,通常涉及计算机科学中的数据结构和算法知识。 解题报告是参赛者在...
"agribarter-landingpage:Agri-Barter跨平台应用程序的着陆页" 这个标题揭示了我们正在讨论的是一个名为Agri-Barter的跨平台应用程序的着陆页面。"Agri-Barter"很可能是一个专注于农业交易的平台,而“着陆页”是...
Sen2Agri-package-{{sen2agri_version}}。zip srtm.zip Maja_3.2.2_TM.zip 该脚本可以与外部数据库一起使用。 的角色 nfs-mount:由于大量数据,特定于我们的项目使用NFS文件系统 maja:需要Sen2Agri服务 sen2...
农业地图 一些用于可视化农业植物间距的代码 要求 matplotlib ... 与运行python agri_map.py默认如图所示运行,其结果。 也可以与命令行参数一起运行以修改输出(与-h标志一起运行以查看可用选项)。
my_vue 一个Vue.js项目构建设置# install dependenciesnpm install# serve with hot reload at localhost:8080npm run dev# build for production with minificationnpm run build# build for production and view ...
标题 "PyPI 官网下载 | agri_tech-0.1.7-py2.py3-none-any.whl" 指的是一个在Python Package Index(PyPI)上发布的软件包,名为 "agri_tech",版本为 "0.1.7"。这个软件包的格式是 wheel(whl),这是一种预编译的...
《Python库agri_tech-0.1.6-py2.py3-none-any.whl详解》 在Python的生态系统中,库是构建复杂应用程序的重要基石。它们提供了丰富的功能,使得开发者能够快速、高效地实现各种任务。本文将深入探讨一个名为`agri_...
【FY4圆盘转等经纬工具】是一款专为处理风云四号A星(FY4A)HDF格式卫星数据而设计的应用程序。风云四号是中国新一代静止气象卫星,其观测数据具有高分辨率和丰富的遥感信息,对于气象预报、环境监测等方面有着重要...
它的方法是与非政府组织Nutri-Fresh Farm&Agri-Hub合作,该非政府组织是由肯尼亚的自给自足农民和青年创建农业企业家的。 每个家庭签署了《家禽项目贷款协议》,其中规定他们有义务无偿还以成年家禽的形式支付雏鸡...
《PyPI官网下载 | agri_tech-0.1.6.tar.gz——探索Python农业技术库》 在Python的世界里,PyPI(Python Package Index)是开发者们分享和获取开源软件包的重要平台。"agri_tech-0.1.6.tar.gz"这个资源就是从PyPI...
它还强调了英语词根的重要性,并通过具体的单词示例,如agri-相关的词汇,来阐述字母在构词中的作用。 【标签】:英语历史、字母演变、词根、语言学 【正文】: 英语字母的演变历程是一部丰富多彩的语言发展史。...
Agri-antibiotics 2507 is a new kind of agri-antibiotics against Oomyces,its analysismethod was established with high performance liquid chromatography ( HPLC) . Agri-antibiotics 2507 could be ...
在"Agri-Net"这道题中,Prim算法的应用帮助解决了构建最短网络的问题。 接着,重复背包问题在"Score Inflation"中被提及,这是一种特殊的背包问题,物品可以无限次放入背包中,利用动态规划可以有效地解决这类问题...