Logo
(追記) (追記ここまで)

27709번 - Broadway 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB53266.667%

문제

The Manhattan in the New York City has really a nice topology. So nice, it is often idealized to a rectangular grid. If you want to go from corner A = (Ax, Ay) to corner B = (Bx, By), the shortest way has length |Ax − Bx| + |Ay − By|. Or so they told you in school.

The truth is, the correct definition of a Manhattan metric has to involve the Broadway – a road that leads across the neatly aligned system of streets and avenues. In this problem we finally correct this horrible mistake made by the mathematical community.

Given the two corners A = (Ax, Ay),B = (Bx, By) and three rational numbers P, Q, R that describe the Broadway, your task is to find the length of the shortest path between points A and B.

The road network consists of the following roads:

  • For each integer Z, there is an avenue described by the equation x = Z.
  • For each integer Z, there is a street described by the equation y = Z.
  • The Broadway is described by the equation Px + Qy = R.

When moving from A to B, we can only move along the roads and change roads at intersections.

입력

The first line of the input file contains an integer T specifying the number of test cases. Each test case is preceded by a blank line.

Each test case consists of one line containing seven numbers: four integers Ax, Ay, Bx, By specifying the points A = (Ax, Ay) and B = (Bx, By), and three rational numbers P, Q, R specifying the Broadway as explained above.

출력

For each test case output a single line containing the length of the shortest path from A to B. Output a sufficient number of decimal places. Your output will be judged as correct if it has an absolute or relative error at most 10−9.

제한

P, Q, R is given to exactly 10 decimal places.

Easy (1점)

  • -1 000 ≤ Ax, Ay, Bx, By ≤ 1 000
  • -200 ≤ P ≤ 200
  • Q = 1
  • -20 000 ≤ R ≤ 20 000

Hard (2점)

  • -1 000 000 ≤ Ax, Ay, Bx, By ≤ 1 000 000
  • -25 ≤ P ≤ 25
  • Q = 1
  • -2 000 000 ≤ R ≤ 2 000 000

예제 입력 1

2
2 0 -1 1 1.0 1.0 1.0
-2 3 4 -1 1.0 -0.1 0.47

예제 출력 1

3.414213562373
10

힌트

출처

Contest > Internet Problem Solving Contest > IPSC 2010 B번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /