아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Spider-Fly

시간 제한1초메모리 제한1024 MB

요약
직육면체 방의 표면 위 두 점이 주어질 때 벽과 바닥, 천장을 따라 이동하는 최단 경로의 길이를 구한다. 상자를 평면으로 펼쳐 가능한 전개도마다 두 점 사이의 직선 거리를 계산하고 그 최솟값을 취한다.
난이도

보통10점 중 7점

유형
기하, 완전 탐색, 구현, 수학
정답자
아직 제출이 없습니다

문제

In the English newspaper Weekly Dispatch on 14 June 1903, Henry Dudeny posed the following problem (that’s right, everyone is now typing “henry dudeny spider fly” into Google search).

In a room 12 feet wide, 12 feet high and 30 feet long, there is a spider 1 foot from the ceiling and horizontally centered on one end wall. There is a fly 1 foot from the floor and horizontally centered on the opposite wall. What is the shortest path (in feet) the spider can walk across walls, ceiling or floor to reach the fly?

Several possible paths are shown below together with their lengths. The 40 foot path is (one of) the shortest.

Write a program which solves the general spider-fly problem.

입력

The input will use a coordinate system with origin at a corner of the room. The x-axis in the direction of the width, the y-axis in the direction of the height and the z-axis in the direction of the length so that 0 ≤ x ≤ Width, 0 ≤ y ≤ Height and 0 ≤ z ≤ Length:

The input consists of three lines of input. The first input line contains three double precision decimal numbers giving the Width, Height and Length (in feet) in that order (0 < WIdth, Height, Length ≤ 30). The second line consists of three double precision decimal numbers: x, y and z, in that order, giving the coordinates of the spider. The third line consists of three double precision decimal numbers: x, y and z, in that order, giving the coordinates of the fly. In each of the latter two lines, the points will be on a wall, the floor or the ceiling, that is: either x = 0 OR x = Width OR y = 0 OR y = Height OR z = 0 OR z = Length.

출력

The single output line consists of a single floating point decimal value, accurate to three decimal places, giving the length of the shortest path in feet.

예제1

  1. 예제 1

    입력
    12 12 30
    6 11 0
    6 1 30
    
    예상 출력
    40.000