Kattis - Different Distances

 

 

Input

The input file contains up to 1000 test cases,

x1 y1 x2 y2 p,

10 digits past the decimal point.

(0,100]. The last test case is followed by a line containing a single zero.

Output

For each test case output the (x2,y2).

0.0001 error.

Sample Input 1 Sample 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\n", sum);
    }
    return 0;
}

相关文章:

  • 2021-10-16
  • 2022-12-23
  • 2022-02-01
  • 2021-08-22
  • 2021-07-28
  • 2022-01-11
  • 2022-01-14
  • 2021-06-05
猜你喜欢
  • 2021-08-21
  • 2021-06-16
  • 2021-08-12
  • 2021-09-22
  • 2022-01-28
  • 2021-06-14
  • 2021-12-04
相关资源
相似解决方案