编程介的小学生 2019-01-19 23:18 采纳率: 20.5%
浏览 443
已采纳

超空间体的三维距离的计算,采用向量的方式的算法实现,怎么利用C语言解决

Problem Description
Hyperspace ,A Euclidean space of dimension greater than three (the original meaning of the word hyperspace, common in late nineteenth century British books, sometimes used in paranormal context, but which has become rarer since then). Minkowski space, a concept, often referred to by science fiction writers as hyperspace that refers to the four-dimensional space-time of special relativity.

Here we define a “Hyperspace” as a set of points in three-dimensional space. We define a function to describe its “Hyperspace Value”

Every vi (0<=i<=k) could be describe in three-dimensional reference system, say v0 (1, 2, 3)
For the following question, we will have to deal with the “Hyperspaces”, you may assume that the number of “Hyperspace” is always no larger than 100.
As we say above, we give every “Hyperspace” an “ID” to identify it.
If you want to connect two points in two different “Hyperspaces”, it will cost you F to build the connection. F can be defined as the following expression:

In addition, you can only create at most one connection between any two “Hyperspaces”.
If you want to connect two points in the same “Hyperspaces” whose “ID” is k, it will cost you G to build the connection. G can be defined as the following expression:

Here

Now your task is quite easy.
AekdyCoin gives you n “Hyperspaces”.
Then he gives you information about all the points in the “Hyperspaces”
Now he wants to know the minimal cost to connect all the points in all “Hyperspaces”

you have to ensure that any two different points in the same "Hyperspace" could be connected directly or indirectly by the connections you build in this "Hyperspace".

Input
The input consists of several test cases.
In the first line there is an integer n (1<=n<=100), indicating the number of “Hyperspaces”
Then follow an integer m (1<=m<=100000)
You can assume that the number of different points in every “Hyperspace” is always no larger than 100.
The next m lines contain the descriptions of all the points
All the descriptions are given in the following format x,y,z,id
Indicating the point (x,y,z) belongs to the id “Hyperspace”
id is an integer.
x,y,z are all real number with at most four fractional digits.
-10000<=x,y,z<=10000,1<=id<=n

Output
For each test case, output the minimal cost on a single line.
Please round it to four fractional digits.

Sample Input
1
2
1 2 1 1
1 3 1 1

Sample Output
1.0000

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-01-07 01:31
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题