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=c and y=c for every integer c (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) for which ax+by+c=0 .
One can walk along streets, including the avenue. You are given two integer points A and B somewhere in Barcelona. Find the minimal possible distance one needs to travel to get to B from A .
输入格式
The first line contains three integers a , b and c ( −109≤a,b,c≤109 , at least one of a and b is not zero) representing the Diagonal Avenue.
The next line contains four integers x1 , y1 , x2 and y2 ( −109≤x1,y1,x2,y2≤109 ) denoting the points A=(x1,y1) and B=(x2,y2) .
输出格式
Find the minimum possible travel distance between A and B . Your answer is considered correct if its absolute or relative error does not exceed 10−6 .
Formally, let your answer be a , and the jury's answer be b . Your answer is accepted if and only if max(1,∣b∣)∣a−b∣≤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.