青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 74,  comments - 33,  trackbacks - 0
Building a Space Station
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 548 Accepted: 347

Description

You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.
The space station is made up with a number of units, called cells. All cells are sphere-shaped, but their sizes are not necessarily uniform. Each cell is fixed at its predetermined position shortly after the station is successfully put into its orbit. It is quite strange that two cells may be touching each other, or even may be overlapping. In an extreme case, a cell may be totally enclosing another one. I do not know how such arrangements are possible.

All the cells must be connected, since crew members should be able to walk from any cell to any other cell. They can walk from a cell A to another cell B, if, (1) A and B are touching each other or overlapping, (2) A and B are connected by a `corridor', or (3) there is a cell C such that walking from A to C, and also from B to C are both possible. Note that the condition (3) should be interpreted transitively.

You are expected to design a configuration, namely, which pairs of cells are to be connected with corridors. There is some freedom in the corridor configuration. For example, if there are three cells A, B and C, not touching nor overlapping each other, at least three plans are possible in order to connect all three cells. The first is to build corridors A-B and A-C, the second B-C and B-A, the third C-A and C-B. The cost of building a corridor is proportional to its length. Therefore, you should choose a plan with the shortest total length of the corridors.

You can ignore the width of a corridor. A corridor is built between points on two cells' surfaces. It can be made arbitrarily long, but of course the shortest one is chosen. Even if two corridors A-B and C-D intersect in space, they are not considered to form a connection path between (for example) A and C. In other words, you may consider that two corridors never intersect.

Input

The input consists of multiple data sets. Each data set is given in the following format.

n
x1 y1 z1 r1
x2 y2 z2 r2
...
xn yn zn rn

The first line of a data set contains an integer n, which is the number of cells. n is positive, and does not exceed 100.

The following n lines are descriptions of cells. Four values in a line are x-, y- and z-coordinates of the center, and radius (called r in the rest of the problem) of the sphere, in this order. Each value is given by a decimal fraction, with 3 digits after the decimal point. Values are separated by a space character.

Each of x, y, z and r is positive and is less than 100.0.

The end of the input is indicated by a line containing a zero.

Output

For each data set, the shortest total length of the corridors should be printed, each in a separate line. The printed values should have 3 digits after the decimal point. They may not have an error greater than 0.001.

Note that if no corridors are necessary, that is, if all the cells are connected without corridors, the shortest total length of the corridors is 0.000.

Sample Input

3
10.000 10.000 50.000 10.000
40.000 10.000 50.000 10.000
40.000 40.000 50.000 10.000
2
30.000 30.000 30.000 20.000
40.000 40.000 40.000 20.000
5
5.729 15.143 3.996 25.837
6.013 14.372 4.818 10.671
80.115 63.292 84.477 15.120
64.095 80.924 70.029 14.881
39.472 85.116 71.369 5.553
0

Sample Output

20.000
0.000
73.834

Source

Japan 2003 Domestic
我暈 剛讀懂題目意思
我還想用Floyd簡化的處理下就行了,沒想到有點之間不能實現,看來不能偷懶,
只能用Dijiskal做了
代碼如下
for(i=0;i<n;i++){
????????????memset(flag,
0,sizeof(flag));
????????????
for(j=0;j<n;j++)
????????????????dis[j]
=map[i][j];
????????????
double?sum,Min;
????????????
int?sign;
????????????sum
=0;
????????????flag[i]
=1;
????????????
for(j=1;j<n;j++){
????????????????Min
=10000000;
????????????????
for(k=0;k<n;k++)
????????????????????
if(!flag[k]&&dis[k]<Min){
????????????????????????Min
=dis[k];
????????????????????????sign
=k;????
????????????????????}

????????????????flag[sign]
=1;
????????????????sum
+=Min;
????????????????
for(k=0;k<n;k++)
????????????????????
if(!flag[k]&&map[sign][k]<dis[k])
????????????????????????dis[k]
=map[sign][k];
????????????}

????????????
if(sum<min)min=sum;????
????????}
posted on 2009-02-20 21:51 KNIGHT 閱讀(209) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2025年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用鏈接

留言簿(8)

隨筆檔案

文章檔案

Friends

OJ

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            美女主播精品视频一二三四| 欧美成人激情视频| 久久免费视频这里只有精品| 欧美成年视频| 噜噜噜噜噜久久久久久91| 亚洲欧洲一区二区三区| 亚洲在线观看免费| 欧美国产在线观看| 欧美一区二区在线免费播放| 欧美mv日韩mv国产网站| 国户精品久久久久久久久久久不卡| 日韩小视频在线观看| 久久久女女女女999久久| 久久大香伊蕉在人线观看热2| 欧美午夜一区二区福利视频| 亚洲国产精品99久久久久久久久| 久久精品国产免费观看| 亚洲天堂免费观看| 欧美精品一区二区三区在线看午夜 | 亚洲电影av| 欧美一区二区视频在线观看2020| 最新国产拍偷乱拍精品| 日韩视频三区| 欧美jizz19性欧美| 欧美日韩网站| 国产精品99久久久久久www| 亚洲黄色一区| 国产伦精品一区二区三区视频黑人| 在线亚洲精品福利网址导航| 亚洲人成在线观看网站高清| 欧美成人dvd在线视频| 亚洲高清网站| 亚洲免费视频网站| 国产日韩免费| 久久久噜噜噜久噜久久 | 亚洲一区二区三区免费视频| 欧美日韩久久| 99国产精品久久久| 欧美制服第一页| 影音先锋亚洲视频| 欧美国产大片| 欧美女人交a| 老司机久久99久久精品播放免费| 久久成人精品视频| 亚洲午夜久久久| 亚洲宅男天堂在线观看无病毒| 亚洲国产精品欧美一二99| 午夜精品久久久久久久久| 国产一区二区高清不卡| 久久综合99re88久久爱| 老司机精品久久| 一区二区三区视频在线观看 | 亚洲精品一区在线观看香蕉| 欧美午夜剧场| 亚洲毛片在线看| 亚洲精品国产拍免费91在线| 99精品视频免费观看视频| 国产精品久久久久久久久久久久久| 亚洲欧美日韩一区在线| 久久国产精品99精品国产| 亚洲——在线| 欧美视频不卡| 美女网站在线免费欧美精品| 欧美国产日韩一区二区在线观看 | 亚洲人成人99网站| 久久中文字幕一区二区三区| 久久理论片午夜琪琪电影网| 国产日韩亚洲欧美综合| 先锋亚洲精品| 日韩亚洲欧美在线观看| 美女在线一区二区| 亚洲精品1区2区| 日韩一区二区久久| 欧美日韩成人在线观看| 夜夜夜精品看看| 亚洲欧美国产va在线影院| 国产精品v欧美精品v日本精品动漫| 亚洲精品婷婷| 亚洲欧美日韩区| 国语自产精品视频在线看一大j8| 亚洲看片免费| 午夜激情亚洲| 欧美激情亚洲综合一区| 久久永久免费| 亚洲国产欧美日韩| 久久精品国产999大香线蕉| 美女视频黄免费的久久| 亚洲国产裸拍裸体视频在线观看乱了中文 | 午夜精品福利在线观看| 久久福利毛片| 国产精品久久久久久久午夜片| 欧美91大片| 亚洲免费电影在线观看| 国产精品国产三级国产普通话99| 亚洲综合电影一区二区三区| 久久漫画官网| 艳女tv在线观看国产一区| 久久在线免费观看视频| 亚洲精品小视频在线观看| 久久精品国亚洲| 亚洲激情社区| 国产精品稀缺呦系列在线| 亚洲性感美女99在线| 久久亚洲色图| 亚洲一级在线观看| 亚洲第一区在线| 国产精品欧美日韩一区| 久久久精品动漫| 免费在线一区二区| 亚洲在线日韩| 亚洲国内精品| 国产女优一区| 性欧美xxxx视频在线观看| 亚洲国产高清aⅴ视频| 亚洲激情午夜| 国产日韩精品一区二区三区在线| 欧美va日韩va| 久久免费视频网站| 欧美激情无毛| 久久久国产视频91| 1000部精品久久久久久久久| 欧美日韩综合一区| 欧美成人免费在线观看| 久久精品国产第一区二区三区最新章节 | 亚洲在线第一页| 99精品免费| 亚洲第一精品电影| 国产一区激情| 国产精品网站一区| 国产精品爱久久久久久久| 欧美成人亚洲| 免费欧美视频| 久久综合婷婷| 久久一二三国产| 久久久久久久久久久久久女国产乱 | 欧美在线免费观看| 午夜精品久久99蜜桃的功能介绍| 日韩一级片网址| 亚洲九九精品| 日韩午夜在线视频| 亚洲精品美女久久久久| 亚洲高清在线| 亚洲黑丝一区二区| 最新日韩精品| 亚洲精品网址在线观看| 亚洲精品久久久久久一区二区| 亚洲国产精品久久久久秋霞蜜臀| 一区二区在线观看视频在线观看| 欧美高清在线视频观看不卡| 麻豆精品91| 欧美a级一区| 欧美日韩国语| 国产精品久久久一本精品| 国产精品久久久久久久久久直播 | 久久aⅴ国产紧身牛仔裤| 欧美一区二区日韩一区二区| 欧美一级久久久| 久久精品99国产精品酒店日本| 久久国产加勒比精品无码| 噜噜噜在线观看免费视频日韩| 欧美国产日韩一区二区三区| 欧美日本中文字幕| 国产精品人人做人人爽| 国产一二三精品| 亚洲国产欧美国产综合一区| 妖精视频成人观看www| 午夜视频久久久| 久久一区二区三区国产精品| 亚洲福利专区| 亚洲一级二级| 久久久免费av| 欧美激情精品久久久久| 国产精品美女诱惑| 激情久久综艺| 中文高清一区| 久久久久九九九| 亚洲欧洲精品一区二区| 亚洲在线黄色| 欧美freesex8一10精品| 国产精品日韩精品欧美精品| 一区视频在线播放| 亚洲伊人观看| 欧美77777| 午夜精品成人在线| 欧美激情第1页| 国产在线一区二区三区四区| 日韩网站在线看片你懂的| 欧美在线观看一区二区| 亚洲国产精品精华液网站| 欧美激情精品久久久久久大尺度 | 亚洲国产裸拍裸体视频在线观看乱了中文| 亚洲免费播放| 一本到12不卡视频在线dvd| 欧美中文在线视频| 欧美日韩一区二区三区视频| 国内成+人亚洲| 午夜国产欧美理论在线播放 | 午夜精品久久| 日韩视频不卡| 免费亚洲婷婷|