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

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 閱讀(197) 評論(0)  編輯 收藏 引用
<2009年2月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

常用鏈接

留言簿(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>
            亚洲美女精品成人在线视频| 久久视频精品在线| 亚洲国产成人高清精品| 午夜欧美电影在线观看| 国产精品手机视频| 午夜精品免费| 亚洲一区一卡| 国产精品一区二区三区免费观看| 亚洲第一网站免费视频| 欧美bbbxxxxx| 蘑菇福利视频一区播放| 亚洲人成网站777色婷婷| 亚洲国产欧美一区| 欧美日韩成人激情| 亚洲一级网站| 午夜激情亚洲| 怡红院精品视频在线观看极品| 美女精品视频一区| 欧美大片在线观看一区| 一区二区高清视频在线观看| 欧美激情视频一区二区三区在线播放 | 国产精品天美传媒入口| 亚洲特级毛片| 亚洲欧美福利一区二区| 精品999在线播放| 欧美激情麻豆| 国产精品久久久久久亚洲毛片 | 欧美精品成人91久久久久久久| 亚洲伦理在线| 亚洲视频专区在线| 国产亚洲精品久久久久久| 美女图片一区二区| 欧美日韩国产小视频| 欧美影院一区| 欧美成人a视频| 午夜欧美精品| 久久综合久久综合这里只有精品| 亚洲第一天堂av| 一区二区三区不卡视频在线观看| 国内精品伊人久久久久av一坑| 欧美福利一区二区| 国产精品久久久久久影视| 久久综合久色欧美综合狠狠 | 亚洲国产成人av在线| 国产精品视频观看| 亚洲国产婷婷香蕉久久久久久| 国产精品尤物| 亚洲人成网站影音先锋播放| 国产婷婷色一区二区三区在线| 亚洲国产婷婷综合在线精品| 国产视频久久久久久久| 亚洲精品一区二区三区婷婷月| 国内精品久久久久久影视8| 亚洲国产精品va| 国产综合视频在线观看| 日韩一级欧洲| 亚洲人体偷拍| 久久成人在线| 欧美伊人久久| 国产精品久久久久久久电影| 欧美激情视频一区二区三区在线播放| 国产欧美va欧美va香蕉在| 欧美风情在线观看| 一区二区三区在线免费观看| 亚洲欧美国内爽妇网| 亚洲男同1069视频| 欧美丝袜一区二区| 亚洲日本一区二区| 亚洲乱码视频| 欧美电影免费观看| 欧美高清视频一区| 亚洲第一精品影视| 老鸭窝毛片一区二区三区| 久久亚洲美女| 在线观看成人av电影| 久久精品91久久香蕉加勒比| 久久精品99| 国产精品乱码久久久久久| 女仆av观看一区| 亚洲高清视频在线观看| 久久一区二区精品| 欧美插天视频在线播放| 亚洲大胆在线| 欧美成人免费全部观看天天性色| 欧美大片va欧美在线播放| 亚洲国产另类久久久精品极度| 久久亚洲春色中文字幕| 欧美99在线视频观看| 在线高清一区| 欧美精品性视频| 一区二区欧美日韩视频| 亚洲一区欧美| 国产伦精品一区二区三区照片91| 午夜电影亚洲| 免费观看日韩av| 亚洲精品激情| 国产精品久久久久免费a∨大胸| 99精品热视频只有精品10| 亚洲欧美在线观看| 国产在线观看91精品一区| 久久亚洲精品一区| 99国产精品国产精品毛片| 欧美一区二区三区男人的天堂| 国产一区二区电影在线观看 | 久久夜色精品国产噜噜av| 黄色精品一二区| 免费在线亚洲| 亚洲一区二区毛片| 欧美 日韩 国产在线| 一本色道久久综合亚洲精品不卡 | 欧美精品在线一区二区| 亚洲午夜小视频| 欧美11—12娇小xxxx| 亚洲午夜国产成人av电影男同| 国产欧美 在线欧美| 亚洲免费视频一区二区| 欧美激情视频在线播放| 午夜久久久久久久久久一区二区| 一区二区三区我不卡| 欧美视频精品一区| 亚洲一区二区视频| 亚洲福利av| 久久亚洲不卡| 亚洲欧美日韩精品综合在线观看| 一区视频在线播放| 欧美午夜无遮挡| 久久久久久网站| 亚洲第一狼人社区| 午夜亚洲性色视频| 夜色激情一区二区| 黄色成人精品网站| 国产欧美日韩一区| 欧美性色综合| 欧美大片免费久久精品三p| 午夜视频久久久| 正在播放欧美视频| 欧美国产日产韩国视频| 久久婷婷久久一区二区三区| 午夜欧美大尺度福利影院在线看| 亚洲剧情一区二区| 亚洲第一成人在线| 激情一区二区| 欧美特黄视频| 久久久久网站| 久久国产精品色婷婷| 午夜久久久久久| 亚洲综合成人在线| 欧美一级二区| 久久精品伊人| 欧美aaaaaaaa牛牛影院| 免费国产一区二区| 欧美精品偷拍| 国产精品人人做人人爽| 国产精品五区| 精品69视频一区二区三区| 在线成人av.com| 一区二区毛片| 欧美一区=区| 欧美bbbxxxxx| 亚洲伦理久久| 午夜亚洲一区| 免费日韩精品中文字幕视频在线| 欧美黄色精品| 国产农村妇女毛片精品久久莱园子| 国产日韩综合| 亚洲精品国产精品久久清纯直播| 亚洲最新在线视频| 久久精品一区二区三区不卡牛牛| 男男成人高潮片免费网站| 最新中文字幕一区二区三区| 一区二区三区欧美日韩| 久久精品久久综合| 欧美女人交a| 国产一区99| av成人毛片| 久久手机精品视频| 日韩亚洲欧美成人| 久久久噜噜噜久久久| 欧美色道久久88综合亚洲精品| 国产日韩亚洲欧美精品| 亚洲乱亚洲高清| 久久综合久久久久88| 中文欧美在线视频| 免费日韩成人| 国产一区二区三区在线播放免费观看 | 亚洲一区二区三区中文字幕 | 亚洲视频久久| 欧美国产日本在线| 国产在线精品一区二区夜色| 日韩视频一区| 狼人天天伊人久久| 亚洲一区二区三区涩| 欧美国产日韩免费| 伊人精品视频| 久久福利毛片| 99国产精品国产精品毛片| 免费成年人欧美视频| 狠狠爱www人成狠狠爱综合网| 亚洲男人的天堂在线| 最新亚洲视频|