A frog in the desert

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

요약
시작점과 도착점, 그리고 최대 5개의 순간이동 거리가 주어질 때, 정해진 길이의 순간이동을 사용해 최단 경로를 찾고 각 이동 후 좌표를 출력한다.
난이도

보통10점 중 4점

유형
기하, 최단 경로, 수학
정답자
아직 제출이 없습니다

문제

In the endless desert at point AA there is a strategic nuclear submarine "The Frog"\ buried in the sand. The military headquarters decided to change the dislocation of The Frog to point BB. Without having any chance to cancel that decision it came an issue to find out how the buried submarine could be moved from one point of the flat desert to another.

It turned out that The Frog's design engineering team solved that problem years ago during construction stage. Design engineers installed the real teleport on The Frog. The problem seemed over, as it turned out that the teleport has only KK operation modes which differ only in the teleportation distance, that is for each mode there is a predefined distance L_iL\_i, which the submarine would move in a given direction.

It is necessary to find the minimal total route distance for The Frog to be moved to destination point.

입력

The first line contains five integers X_A,Y_A,X_B,Y_BX\_A, Y\_A, X\_B, Y\_B (−150≤X_A,Y_A,X_B,Y_B≤150-150 \le X\_A, Y\_A, X\_B, Y\_B \le 150) --- Cartesian coordinates of two different points AA and BB, and KK (0<K≤50 < K \le 5) --- the number of teleport modes. The second line contains KK integers L_iL\_i (0<Li≤1500 < Li \le 150) --- the teleportation distance for each operation mode.

출력

In the first line output the minimal route distance.

In the second line output number MM --- the count of teleportations in the minimal route.

In the following MM lines output 2 real numbers each with the accuracy up to 10−610^{-6} --- coordinates (x_ix\_i, y_iy\_i), where The Frog will be found after ii-th teleportation.

If there are several minimal routes, output any of them.

예제2

  1. 예제 1

    입력
    1 1 4 5 3
    2 3 5
    
    예상 출력
    5
    2
    2.2000000000 2.6000000000
    4.0000000000 5.0000000000
    
  2. 예제 2

    입력
    0 0 18 0 2
    10 5
    
    예상 출력
    20
    3
    4 3
    14 3
    18 0