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. Linux系统下打印第n行的方法

    方法一:cat cat filename | head -n 5 | tail -n +5 方法二:sed sed -n '5p' filename 扩展:打印第3~5行 cat filename | ...

  2. 【hihocoder 1298】 数论五·欧拉函数

    [题目链接]:http://hihocoder.com/problemset/problem/1298 [题意] [题解] 用欧拉筛法; 能够同时求出1..MAX当中的所有质数和所有数的欧拉函数的值; ...

  3. adchos 文本混淆工具

    #-*- coding:utf-8 -*- import jieba import random import codecs import sys import string import chard ...

  4. 教你 Shiro + SpringBoot 整合 JWT

    本篇文章将教大家在 shiro + springBoot 的基础上整合 JWT (JSON Web Token) 如果对 shiro 如何整合 springBoot 还不了解的可以先去看我的上一篇文章 ...

  5. Spring Boot-properties使用(二)

    自定义属性 @value注入 在application.properties新增配置 student.name=小明student.age=12student.info=${student.name} ...

  6. HDU 4531

    很容易判断是BFS,可是,呵呵呵呵呵呵......... HASH判重吧,判连通可以用并查集. 以下代码是转别人的,我码了一下午,发觉越码越丑,呵呵了. http://www.cnblogs.com/ ...

  7. Eclipse快捷操作

    Eclipse快捷操作 快捷操作,包含了一些鼠标的操作: 学习了:http://www.cnblogs.com/iamfy/archive/2012/07/11/2586869.html 自己体会了一 ...

  8. Android入门:短信和拨打电话

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...

  9. 例题 2-1 aabb 2-2 3n+1问题

    例题2-1  aabb 输出全部形如aabb的四位全然平方数(即前两位数字相等,后两位数字也相等) #include <stdio.h> #include <stdlib.h> ...

  10. 调试中的step into step over step out

    step into/step out/step over的差别 step into就是单步运行,遇到子函数就进入而且继续单步运行: step over是在单步运行时,在函数内遇到子函数时不会进入子函数 ...