编程介的小学生 2017-02-13 01:39 采纳率: 20.5%
浏览 811
已采纳

Slalom

问题描述 :

Egypt

In spite of the scarcity of snowfall in Syria, interest in winter sports is growing in the country, especially with regard to skiing. Many people spend several weekends or even full weeks improving their skills in the mountains.

In this problem we deal with only one of the multiple alpine skiing disciplines: slalom. A course is constructed by laying out a series of gates, which are formed by two poles. The skier must pass between the two poles forming each gate. The winner is the skier who takes the least time to complete the course while not missing any of the gates.

You have recently started to learn to ski, but you have already set yourself the goal of taking part in the Winter Olympic Games of 2022, for which Syria will presumably present a candidature. As part of the theoretical training, you need to write a program that calculates, given a starting point and a series of gates, the minimum-length path starting from the point given and passing through each gate until you reach the last one, which is the finish line. You may assume that the gates are horizontal and are ordered from highest to lowest, so that you need to pass through them in order. You consider yourself an accomplished skier, so you can make any series of turns, no matter how difficult, and your only concern is minimizing the total length of the path.
输入:

The first line of each case gives the number of gates n (1 ≤ n ≤ 1 000). The next line contains two floating point numbers, the Cartesian coordinates x and y of the starting position, in that order. Next come n lines with three floating point numbers each, y x1 x2, meaning that the next gate is a horizontal line from (x1,y) to (x2,y). You can safely assume that x1 <x2. The values of y are strictly decreasing and are always smaller than that of the starting position.The last gate represents the finish line. All coordinates are between -500 000 and 500 000,inclusive. A value of 0 for n means the end of the input. A blank line follows each case.
输出:

The first line of each case gives the number of gates n (1 ≤ n ≤ 1 000). The next line contains two floating point numbers, the Cartesian coordinates x and y of the starting position, in that order. Next come n lines with three floating point numbers each, y x1 x2, meaning that the next gate is a horizontal line from (x1,y) to (x2,y). You can safely assume that x1 <x2. The values of y are strictly decreasing and are always smaller than that of the starting position.The last gate represents the finish line. All coordinates are between -500 000 and 500 000,inclusive. A value of 0 for n means the end of the input. A blank line follows each case.
样例输入:

2
0 2
1 1 2

0 0.5 3

3
0 4
3 1 2
2 -1 0
1 1 2

0
样例输出:

2.41421356237
4.24264068712

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题