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

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簡(jiǎn)化的處理下就行了,沒想到有點(diǎn)之間不能實(shí)現(xiàn),看來不能偷懶,
只能用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) 評(píng)論(0)  編輯 收藏 引用

只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2009年2月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

常用鏈接

留言簿(8)

隨筆檔案

文章檔案

Friends

OJ

搜索

  •  

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲欧洲一区二区天堂久久| 久久久久久夜精品精品免费| 欧美在线一级视频| 亚洲新中文字幕| 欧美成人午夜免费视在线看片| 欧美一级午夜免费电影| 欧美激情一区二区三区蜜桃视频 | 国产精品一区二区欧美| 亚洲美女在线看| 久久久久欧美精品| 久久久久久久波多野高潮日日| 欧美美女视频| 亚洲国产精品久久精品怡红院 | 亚洲国产日韩综合一区| 午夜精品久久久| 国产精品一二一区| 亚洲视频免费在线观看| 在线性视频日韩欧美| 欧美精品久久久久久久免费观看 | 国产精品久久亚洲7777| 日韩午夜av在线| 欧美日韩三级在线| 亚洲三级观看| 亚洲一级在线观看| 欧美性色综合| 亚洲线精品一区二区三区八戒| 一本一道久久综合狠狠老精东影业 | 亚洲大胆女人| 亚洲大胆美女视频| 久久影视三级福利片| 免费成人在线视频网站| 影音先锋亚洲精品| 久久久另类综合| 欧美激情成人在线视频| 亚洲精品一区二区在线| 欧美夫妇交换俱乐部在线观看| 在线日本成人| 免费视频一区| 日韩一二在线观看| 午夜激情综合网| 国产欧美日韩麻豆91| 香港久久久电影| 美国十次成人| 99视频超级精品| 国产精品久久午夜夜伦鲁鲁| 久久国产66| 精品51国产黑色丝袜高跟鞋| 麻豆成人av| 日韩视频在线免费观看| 欧美亚洲免费高清在线观看| 黄色免费成人| 欧美精品一区二区精品网 | 亚洲一区亚洲二区| 久久九九国产精品怡红院| 1000精品久久久久久久久| 欧美激情亚洲精品| 亚洲夜间福利| 欧美电影在线观看完整版| 99在线精品视频| 国产综合香蕉五月婷在线| 免费欧美视频| 亚洲欧美国产77777| 欧美成人综合在线| 亚洲综合第一| 亚洲电影天堂av| 国产精品久久久久av| 麻豆国产精品一区二区三区| 夜夜嗨av一区二区三区中文字幕 | 欧美在线播放一区| 亚洲国产小视频在线观看| 亚洲欧美综合v| 亚洲精品美女在线观看| 国产区二精品视| 欧美日韩高清在线| 久久久青草青青国产亚洲免观| 99re视频这里只有精品| 久久尤物视频| 午夜精品三级视频福利| 最新国产成人在线观看| 国产色爱av资源综合区| 欧美四级在线| 欧美激情久久久| 久久精品成人一区二区三区蜜臀| 日韩视频在线播放| 亚洲电影第三页| 浪潮色综合久久天堂| 欧美一级在线视频| 亚洲欧美福利一区二区| 亚洲免费激情| 麻豆精品传媒视频| 久久精品在线观看| 亚洲免费中文字幕| 一区二区三区四区五区精品视频| 亚洲国产精品一区二区第四页av| 国产精品一区二区女厕厕| 欧美日韩一区二区三区在线看 | 久久一区二区三区国产精品 | 亚洲视频导航| 99国产精品99久久久久久| 久久久xxx| 久久国产主播精品| 欧美专区在线播放| 欧美一区影院| 欧美影院在线| 久久精品一区二区三区中文字幕 | 欧美日一区二区在线观看| 免费91麻豆精品国产自产在线观看| 午夜在线视频观看日韩17c| 亚洲欧美中日韩| 欧美一级片久久久久久久| 亚洲一区在线免费| 亚洲欧美视频在线观看视频| 国产精品99久久久久久人| 在线视频欧美日韩| 亚洲欧美在线网| 欧美一区二区精品| 久久精品视频免费播放| 久久综合狠狠综合久久激情| 久久久精品一区| 欧美大秀在线观看| 欧美日韩一区二区在线| 国产精品久久久久久久久久三级 | 日韩写真视频在线观看| 一区二区三区欧美在线| 亚洲永久免费视频| 久久久xxx| 欧美好吊妞视频| 亚洲乱码国产乱码精品精98午夜| 9久草视频在线视频精品| 亚洲欧美成人在线| 久久久久久久尹人综合网亚洲| 久久中文久久字幕| 欧美伦理91| 国产日韩欧美在线播放不卡| 狠狠久久综合婷婷不卡| 亚洲剧情一区二区| 欧美亚洲自偷自偷| 免费看av成人| 亚洲最黄网站| 久久久久久久久久久久久久一区 | 韩国欧美一区| av成人国产| 久久久久成人精品免费播放动漫| 蜜臀av在线播放一区二区三区 | 亚洲一区免费观看| 久久久久久久综合日本| 亚洲第一精品夜夜躁人人躁| 9人人澡人人爽人人精品| 欧美在线亚洲一区| 欧美理论在线播放| 国内一区二区三区在线视频| 欧美a级理论片| 国产精品一区二区久久国产| 亚洲国产精品成人一区二区| 亚洲一区www| 欧美成人精品在线| 亚洲免费在线| 欧美日韩国产精品专区 | 91久久精品国产91性色tv| 亚洲欧美乱综合| 亚洲福利免费| 欧美在线免费| 国产精品成人国产乱一区| 亚洲第一精品夜夜躁人人爽| 亚洲中字在线| 91久久久在线| 久久久久久9| 国产一区亚洲一区| 亚洲欧美综合v| 亚洲最新视频在线| 欧美韩日一区| 伊人久久婷婷| 久久精品亚洲国产奇米99| 一区二区三区精品国产| 麻豆av一区二区三区| 含羞草久久爱69一区| 欧美在线观看视频在线| 中文亚洲免费| 欧美视频三区在线播放| 亚洲人成在线免费观看| 欧美大片第1页| 久久精品最新地址| 国产亚洲视频在线| 久久av一区二区三区漫画| 这里只有精品电影| 欧美午夜精品| 亚洲婷婷在线| 一本色道久久综合亚洲91| 欧美精品在线观看91| 日韩视频中文| 亚洲国产日韩欧美一区二区三区| 久久午夜电影| 亚洲国语精品自产拍在线观看| 男女视频一区二区| 久久一区激情| 亚洲国产综合在线看不卡| 亚洲国产精品尤物yw在线观看| 欧美激情精品久久久六区热门 | 午夜精品久久一牛影视| 亚洲一区二区av电影|