Kattis

 

 

Input

The input file contains up to 10001000 test cases,

each of which contains five real numbers, x1 y1 x2 y2 px1 y1 x2 y2 p,

each of which have at most 1010 digits past the decimal point.

All are in the range (0,100](0,100]. The last test case is followed by a line containing a single zero.

Output

For each test case output the pp-norm distance between the two points (x1,y1)(x1,y1) and (x2,y2)(x2,y2).

The answer should be accurate within 0.00010.0001 error.

Sample Input 1Sample Output 1
1.0 1.0 2.0 2.0 2.0
1.0 1.0 2.0 2.0 1.0
1.0 1.0 20.0 20.0 10.0
0
1.4142135624
2.0000000000
20.3636957882

题意

给出x1,y1,x2,y2,p,按照上面最后一个给出来的公式算,水题,没坑

代码

#include<bits/stdc++.h>
using namespace std;
int main() {
    double x1, y1, x2, y2, p, sum;
    while(scanf("%lf", &x1) && x1 != 0.0) {
        scanf("%lf%lf%lf%lf", &y1, &x2, &y2, &p);
        sum = pow((pow(fabs(x1 - x2), p) + pow(fabs(y1 - y2), p)), 1.0 / p);
        printf("%.10f
", sum);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zhien-aa/p/6294383.html