Khoảng cách Euclide

View as PDF

Time limit: 1.0s , Memory limit: 250M , Points: 1 (partial)

Viết chương trình tính khoảng cách giữa hai điểm phân biệt A(x_1, y_1)B(x_2, y_2) trong mặt phẳng tọa độ Oxy.

Input

Dòng duy nhất chứa bốn số nguyên x_1, y_1, x_2, y_2 thỏa -10^9 \le x_1, y_1, x_2, y_2 \le 10^9.

Output

In ra khoảng cách cần tính làm tròn đến 10^{-9}.

Samples

Sample Input 1
0 0 1 1
Sample Output 1
1.414213562
Sample Input 2
-1 -1 1 1
Sample Output 2
2.828427125
Sample Input 3
13 23 78 23
Sample Output 3
65.000000000

Comments


  • 0
    25T1020086  commented on Oct. 7, 2025, 8:22 a.m.

    include <bits/stdc++.h>

    using namespace std;

    int main() {

    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int xAB = x2 - x1;
    int yAB = y2 - y1;
    double dAB = sqrt(pow(xAB, 2) + pow(yAB, 2));
    
    cout << fixed << setprecision(9) << dAB;
    
    return 0;

    }