编程介的小学生 2019-08-30 22:34 采纳率: 20.5%
浏览 97

代码实现,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 运筹学中在线排序的时间在线排序的在线LPT算法
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试,帮帮忙吧