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

Kattis - Different Distances的更多相关文章

  1. Kattis - Biased Standings

    Biased Standings Usually, results of competitions are based on the scores of participants. However, ...

  2. codeforces 803B Distances to Zero

    Distances to Zero 题目链接:http://codeforces.com/problemset/problem/803/B 题目大意: 给一串数字,求每个数字到离他最近数字0的距离.. ...

  3. [Swift]LeetCode834. 树中距离之和 | Sum of Distances in Tree

    An undirected, connected tree with N nodes labelled 0...N-1 and N-1 edges are given. The ith edge co ...

  4. Codechef Bear and Clique Distances

    题目:Bear and Clique Distances 描述:共有N个点,前1—K个点任意两点之间有一条无向边,边的权值为X,再任意给M条边(u,v,w)(不重复),求任意一点到其余各点的最短路. ...

  5. It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld (等差数列求和取模)

    题目链接: D - It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld 具体的每个参数的代表什么直接看题面就好了. AC代码: ...

  6. A - Piece of Cake Kattis - pieceofcake (数学)

    题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...

  7. Subsequences in Substrings Kattis - subsequencesinsubstrings (暴力)

    题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些 ...

  8. G - Intersecting Rectangles Kattis - intersectingrectangles (扫描线)(判断多个矩形相交)

    题目链接: G - Intersecting Rectangles Kattis - intersectingrectangles 题目大意:给你n个矩形,每一个矩形给你这个矩形的左下角的坐标和右上角 ...

  9. E - Emptying the Baltic Kattis - emptyingbaltic (dijkstra堆优化)

    题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x ...

随机推荐

  1. GOF23设计模式之原型模式

    GOF23设计模式之原型模式 1)通过 new 产生一个对象需要飞船繁琐的数据准备或访问权限,则可以使用原型模式. 2)就算 java 中的克隆技术,以某个对象为原型,复制出新的对象.显然,新的对象具 ...

  2. Automatic Tuning of Memory Management

    4.2.2 Automatic Tuning of Memory Management Two memory management initialization parameters, MEMORY_ ...

  3. 【ACM】hdu_1094_A+BVI_201307261731

    A+B for Input-Output Practice (VI)Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3276 ...

  4. vs code--使用教程

    这是Cnode论坛上的i5ting写的,很详细 教程地址 这个是微软官方的英文版的教程,这个更详细一些 微软官方vs code教程

  5. codevs——T1219 骑士游历

     http://codevs.cn/problem/1219/  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Desc ...

  6. servlet理解

    可得到一个结论:该JSP页面中的每个字符都由test1_jsp.java文件的输出流生成. 根据上面的JSP页面工作原理图,可以得到如下四个结论: — JSP文件必须在JSP服务器内运行. — JSP ...

  7. HDU 5191

    好端端的被HACK掉了...应该是在两端都要补W个0才对,之前只想到要在后面补足0,没想到前面也应该补足,因为前面即便存在0也可能使得移动的积木数最少.. T_T #include <iostr ...

  8. HDU 4515

    刷水完毕,年月日,日日日日日日日日日日日日日日日日日日 #include <stdio.h> ,,,,,,,,,,,,}; ,M = ,D = ; int leap(int y) { == ...

  9. BZOJ 1044 HAOI2008 木棍切割 二分答案+动态规划

    题目大意:给定n个连在一起的木棍.分成m+1段.使每段最大值最小,求最大值的最小值及最大值最小时切割的方案数 第一问水爆了--二分答案妥妥秒过 第二问就有些难度了 首先我们令f[i][j]表示用前j个 ...

  10. 在windows下怎样更新vundle?

    本文出自Svitter的blog 更新Vundle的时候.不管是输出BundleInstall.还是PluginInstall! 都会调用系统的git,所以必须安装git才干达到目的更新插件. git ...