CF1032D.Barcelonian Distance

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In this problem we consider a very simplified model of Barcelona city.

Barcelona can be represented as a plane with streets of kind x=cx = c and y=cy = c for every integer cc (that is, the rectangular grid). However, there is a detail which makes Barcelona different from Manhattan. There is an avenue called Avinguda Diagonal which can be represented as a the set of points (x,y)(x, y) for which ax+by+c=0ax + by + c = 0 .

One can walk along streets, including the avenue. You are given two integer points AA and BB somewhere in Barcelona. Find the minimal possible distance one needs to travel to get to BB from AA .

输入格式

The first line contains three integers aa , bb and cc ( 109a,b,c109-10^9\leq a, b, c\leq 10^9 , at least one of aa and bb is not zero) representing the Diagonal Avenue.

The next line contains four integers x1x_1 , y1y_1 , x2x_2 and y2y_2 ( 109x1,y1,x2,y2109-10^9\leq x_1, y_1, x_2, y_2\leq 10^9 ) denoting the points A=(x1,y1)A = (x_1, y_1) and B=(x2,y2)B = (x_2, y_2) .

输出格式

Find the minimum possible travel distance between AA and BB . Your answer is considered correct if its absolute or relative error does not exceed 10610^{-6} .

Formally, let your answer be aa , and the jury's answer be bb . Your answer is accepted if and only if abmax(1,b)106\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6} .

输入输出样例

  • 输入#1

    1 1 -3
    0 3 3 0
    

    输出#1

    4.2426406871
    
  • 输入#2

    3 1 -9
    0 3 3 -1
    

    输出#2

    6.1622776602
    

说明/提示

The first example is shown on the left picture while the second example us shown on the right picture below. The avenue is shown with blue, the origin is shown with the black dot.

首页