给定一系列孔码,果岭尺寸,切角和最大距离,即可计算出高尔夫球得分。
假设条件
- 地球是平坦的
- 所有果岭都是圆形的
- 切片角度将在-45至45度之间,以度为单位
- 所有距离均以同一度量标准(码或米,无关紧要)
- 没有界限,障碍物或狗腿
- 任何洞的最高分数是8
- 所有镜头在与孔的角度加上切片角度所定义的方向上移动的最大距离或与孔的距离中的较小者。
- 距离以起点或终点之间的直线或欧几里得距离的形式测量。
- 所有孔上的所有镜头的最大距离和切片角度均相同
- 高尔夫球手总是在果岭上两次击球(或者恰好在果岭边缘)。
例
让我们从下面测试用例#5的漏洞#2看一下黑客。黑客可以将球打到320码,但始终会切成30度。如果我们不失一般性地假设发球区框在{0,0}而果岭在{497,0},那么他将击球到以下点,并在第七杆处到达果岭:
{{0.,0.},{277.128,-160.},{547.543,-131.372},{569.457,7.67088},{502.872,37.2564},{479.159,7.92741},{490.646,-7.85868},{500.078,-4.22987}}
此时,由于需要两个推杆,他的分数将为9,因此根据假设,他的最终分数不得超过8。
测试用例
所有测试用例均具有标准的18孔路线
Case#1
{MaxDistance->280,SliceAngle->10,HoleDistances->{181,368,161,416,158,526,377,427,509,148,405,443,510,494,396,388,483,172},GreenDiameters->{26,18,17,23,27,23,21,23,25,21,19,24,21,23,25,24,22,22}}
Scores:
{4,5,4,5,4,5,5,5,5,4,5,5,5,5,5,5,5,4}
Output: 85
Case#2 (same course as Test Case #1, shorter more accurate golfer)
{MaxDistance->180,SliceAngle->5,HoleDistances->{181,368,161,416,158,526,377,427,509,148,405,443,510,494,396,388,483,172},GreenDiameters->{26,18,17,23,27,23,21,23,25,21,19,24,21,23,25,24,22,22}}
Scores:
{4,5,4,5,4,6,5,5,6,4,5,5,6,6,5,5,5,4}
Output: 89
Case#3 (Same golfer as test case #1, shorter course)
{MaxDistance->280,SliceAngle->10,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{4,5,4,5,5,4,4,4,4,5,5,5,4,4,5,5,5,5}
Output: 82
Case#4 (Same course as test case #3)
{MaxDistance->180,SliceAngle->5,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{3,6,3,6,5,4,4,3,3,5,5,5,3,3,5,5,6,5}
Output: 79
Case#5 (Hacker)
{MaxDistance->320,SliceAngle->30,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{6,8,5,8,7,6,6,6,6,8,8,8,6,6,8,8,8,8}
Output: 126
规则
- 任何格式均可用于输入。输出只是模拟笔划的数量,因此应为整数。
- 这是代码高尔夫球,因此最短的答案以字节为单位。有标准漏洞。
MaxDistance
打入洞内绝不会超过6球?
GreenDiameter/2
,在这种情况下,是的,因为得分上限为8,并且总有2个推杆。