编程介的小学生 2020-02-16 01:49 采纳率: 20.5%
浏览 58

Shortest Path on a Cylinder 是怎么编写的呢

Problem Description
Ant Smart is on a surface of cylinder now. He wants to move to another position of the cylinder’s surface. Like many other animals named Smart, he wants to find out the shortest path from one point to another.
Unfortunately, Ant Smart is not enough smart to solve this question now. It is your task to find out the answer.

Input
There are several test cases in this problem. The first line of input contains a single integer denoting the number of test cases.
For each test case, the first line contains two integers: radius and height (1<=radius<=100, 1<=height<=100), denoting the radius and height of the cylinder.
For the next two lines, each line contains three integers: h, a and r (0 <= h <= height, 0 <= a < 360, 0 <= r <= radius), denoting one point on the surface of cylinder each. The h indicates a circle on the surface of cylinder which apart h from the bottom. And the polar angle a and radius r indicates the position of the point on the circle. In the other words, if the cylinder is (0,0,0) - (0,0,height) on the 3D grid coordinate. The point can be represented as (cos(a)*r, sin(a)*r, h).
You may assume that r!=radius only when h=0 or h=height for each point.

Warning: There are about one thousand test cases. Be careful with the time efficiency.

Output
For each test case, output only one line contains the length of the shortest path on the surface of cylinder. The answer should be rounded to two digits after the decimal point.

Sample Input
2
5 10
10 0 3
5 0 5
90 49
49 312 39
0 52 65

Sample Output
Case #1: 7.00
Case #2: 171.02

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 画两个图 python或R
    • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
    • ¥15 八路抢答器设计出现故障
    • ¥15 请教一下c语言的代码里有一个地方不懂
    • ¥15 opencv 无法读取视频
    • ¥15 用matlab 实现通信仿真
    • ¥15 按键修改电子时钟,C51单片机
    • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
    • ¥20 5037端口被adb自己占了
    • ¥15 python:excel数据写入多个对应word文档