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; }