joj2476

来源:互联网 发布:仓库入库软件 编辑:程序博客网 时间:2024/06/14 00:39
[新版judge已支持special judge;增加了提交后的状态页面;增加对提交代码的语言检查] [新版judge系统近日试运行,希望可以解决内存越界导致Waiting的问题] [more]
Welcome, �γɺ�
[JPoints: 905, Sender!: 0/1]

 2476: Star travel


ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s65536K890175Standard

In the future world, one can travel by spaceship from one star to another. Because of the long distance, the fuel consumption is not linear with distance. We should take more material within our spaceship, so the weight of total spaceship increased also. The fuel consumption F can be calculated by this formula.

F= a * d + b * d * d

Here, d is the distance between any two star, a and b are parameters.

Given the coordinates of each star, you should calculate the shortest path between two star. Here, shortest means the least fuel is used.

Input

The first line of each case is the number of stars n (2<=n<=20), and the double parameters a and b. The next n lines includes three double values that are x-axis, y-axis and z-axis coordinates. The next line is one integer m. There are two integers s and t in the next m lines, s and t is star number (from 1).

Output

For each question of each case, find out the shorest path between star s and t. Print the least fuel amount from star s to star t, rounded to 3 digit after the decimal point.

Sample Input

3 1.0 2.0-12.008 82.268 174.26050.033 1.675 108.423211.106 241.439 41.52823 22 1

Sample Output

176108.94629478.812

Problem Source: skywind


This problem is used for contest: 101 


Submit / Problem List / Status / Discuss


原创粉丝点击