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

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>
            亚洲一区二区免费| 亚洲综合色视频| 亚洲国产精品国自产拍av秋霞| 香蕉av777xxx色综合一区| 国产精品久久一区二区三区| 欧美亚洲一区二区在线观看| 欧美一级二区| 91久久久久久久久| av成人免费在线观看| 国产午夜精品久久久久久久| 久久综合激情| 欧美精品一区在线| 久久国产精品一区二区| 欧美成人情趣视频| 亚洲欧美日韩视频二区| 久久亚洲一区二区| 一区二区三区欧美日韩| 欧美一区亚洲一区| 制服丝袜亚洲播放| 久久婷婷人人澡人人喊人人爽| 亚洲精品视频免费在线观看| 亚洲欧美日韩视频二区| 亚洲巨乳在线| 久久精品免视看| 亚洲线精品一区二区三区八戒| 欧美一级久久久| 这里只有精品视频| 麻豆精品精华液| 欧美一区二区网站| 欧美日韩在线第一页| 免费欧美高清视频| 国产女人精品视频| 日韩视频在线观看一区二区| 极品尤物av久久免费看| 亚洲一区二区三区高清不卡| 亚洲精品午夜| 久久一区二区三区国产精品| 欧美伊人影院| 国产精品久久久久av免费| 亚洲激情二区| 亚洲福利免费| 久久精品1区| 欧美影院久久久| 欧美视频一区二区在线观看| 亚洲国产精品黑人久久久| 一区二区视频免费在线观看| 亚洲欧美一区二区三区极速播放| 日韩视频欧美视频| 欧美xxx成人| 欧美激情第9页| 激情亚洲网站| 久久久久国色av免费看影院| 欧美主播一区二区三区美女 久久精品人| 欧美精品在线网站| 最新国产乱人伦偷精品免费网站| 在线欧美日韩| 美女被久久久| 亚洲高清久久久| 亚洲精品欧洲精品| 欧美日韩1区2区| 艳妇臀荡乳欲伦亚洲一区| 在线亚洲一区| 欧美性做爰猛烈叫床潮| 亚洲男人天堂2024| 欧美一区二区三区啪啪| 国产日韩欧美综合精品| 久久精品首页| 欧美高清视频在线播放| 日韩一级黄色大片| 欧美色一级片| 亚洲综合色噜噜狠狠| 久久免费视频这里只有精品| 狠狠色狠狠色综合系列| 美女视频一区免费观看| 亚洲国产欧美一区二区三区同亚洲| 亚洲国产一二三| 欧美女同在线视频| 亚洲一区三区视频在线观看| 久久精品首页| 亚洲国产mv| 欧美日韩美女| 欧美在线欧美在线| 免费精品视频| 亚洲性线免费观看视频成熟| 国产精品入口日韩视频大尺度| 亚洲综合精品一区二区| 蜜桃av一区| 亚洲网友自拍| 精品1区2区| 欧美日韩四区| 久久久久久夜| 一区二区久久久久久| 久久女同互慰一区二区三区| 亚洲精品国产视频| 国产女主播一区二区三区| 老司机精品导航| 一区二区三区视频在线播放| 久久综合图片| 午夜国产欧美理论在线播放 | 亚洲少妇在线| 久久久久国产成人精品亚洲午夜| 亚洲精品专区| 国内一区二区在线视频观看| 欧美人与性禽动交情品 | 久久精品国产99| 亚洲六月丁香色婷婷综合久久| 久久国产精品亚洲77777| 日韩视频不卡| 亚洲国产成人精品女人久久久 | 香蕉亚洲视频| 亚洲三级观看| 黄网站色欧美视频| 国产精品毛片高清在线完整版| 另类欧美日韩国产在线| 亚洲欧美日韩精品在线| 亚洲国产日韩一区| 狂野欧美激情性xxxx欧美| 午夜一区二区三视频在线观看| 99re6这里只有精品| 激情小说亚洲一区| 国产一级久久| 国产日产欧美一区| 国产精品久久久久久av下载红粉| 欧美国产专区| 嫩模写真一区二区三区三州| 久久久久欧美| 久久精品欧洲| 久久精品在线| 久久久久久久综合| 欧美在线观看视频| 性欧美精品高清| 亚洲男女自偷自拍图片另类| 亚洲午夜91| 亚洲午夜成aⅴ人片| 亚洲免费在线观看| 午夜视黄欧洲亚洲| 香蕉国产精品偷在线观看不卡| 亚洲自拍偷拍麻豆| 午夜老司机精品| 欧美一区二区三区久久精品 | 亚洲国产你懂的| 欧美高清在线一区| 亚洲福利视频网站| 亚洲黄色一区| 亚洲免费精品| 亚洲午夜电影在线观看| 欧美亚洲一区三区| 欧美一区激情| 久久久蜜桃一区二区人| 老司机免费视频一区二区| 麻豆乱码国产一区二区三区| 欧美不卡视频| 欧美视频在线视频| 国产欧美在线看| 在线观看日韩av先锋影音电影院| 亚洲国产网站| 亚洲一区美女视频在线观看免费| 亚洲影视中文字幕| 久久久噜噜噜久久人人看| 免费观看亚洲视频大全| 91久久精品日日躁夜夜躁国产| 亚洲免费成人av| 欧美一级久久久| 欧美1级日本1级| 久久精品电影| 久久成人这里只有精品| 国外精品视频| 亚洲国产91精品在线观看| 日韩视频在线一区| 久久国产精品99久久久久久老狼| 久热国产精品| 日韩亚洲欧美中文三级| 西瓜成人精品人成网站| 欧美大片免费久久精品三p| 国产精品萝li| 亚洲人成7777| 久久久久久久一区二区三区| 亚洲国产小视频| 先锋影音久久| 欧美日韩成人在线播放| 好看的av在线不卡观看| 中文国产一区| 免费中文日韩| 亚洲欧美日韩精品在线| 欧美大片免费观看在线观看网站推荐| 国产精品超碰97尤物18| 亚洲人成在线免费观看| 欧美一区二区三区久久精品茉莉花 | 欧美日韩精品伦理作品在线免费观看 | 欧美欧美全黄| 激情综合网激情| 欧美一区影院| 夜夜嗨av一区二区三区| 美女成人午夜| 韩国成人福利片在线播放| 午夜精品一区二区在线观看| 亚洲欧洲综合另类在线| 久久精品最新地址| 国产丝袜美腿一区二区三区| 在线午夜精品自拍|