Kattis - Different Distances

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.4142135624 |
题意
给出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的更多相关文章
- Kattis - Biased Standings
Biased Standings Usually, results of competitions are based on the scores of participants. However, ...
- codeforces 803B Distances to Zero
Distances to Zero 题目链接:http://codeforces.com/problemset/problem/803/B 题目大意: 给一串数字,求每个数字到离他最近数字0的距离.. ...
- [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 ...
- Codechef Bear and Clique Distances
题目:Bear and Clique Distances 描述:共有N个点,前1—K个点任意两点之间有一条无向边,边的权值为X,再任意给M条边(u,v,w)(不重复),求任意一点到其余各点的最短路. ...
- It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld (等差数列求和取模)
题目链接: D - It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld 具体的每个参数的代表什么直接看题面就好了. AC代码: ...
- A - Piece of Cake Kattis - pieceofcake (数学)
题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...
- Subsequences in Substrings Kattis - subsequencesinsubstrings (暴力)
题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些 ...
- G - Intersecting Rectangles Kattis - intersectingrectangles (扫描线)(判断多个矩形相交)
题目链接: G - Intersecting Rectangles Kattis - intersectingrectangles 题目大意:给你n个矩形,每一个矩形给你这个矩形的左下角的坐标和右上角 ...
- E - Emptying the Baltic Kattis - emptyingbaltic (dijkstra堆优化)
题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x ...
随机推荐
- python3实现UDP协议的简单服务器和客户端
利用python中的socket模块中的来实现UDP协议,这里写一个简单的服务器和客户端.为了说明网络编程中UDP的应用,这里就不写图形化了,在两台电脑上分别打开UDP的客户端和服务端就可以了. UD ...
- QT的creator中图示
不同的开发工具显示class和相关的用不同的图标表示.但大同小异.但对于QT的creator中图示确实不太好分.看图一目了然.
- cannot find -lGL
解决方法: 以下操作都在root权限下进行! 1.按照提示安装对应的库文件,fedora安装库件的格式:yum install libxxx(你要装的库),如果已经安装GL库,会显示已经安装 Ps:如 ...
- mysql 的load data infile
LOAD DATA INFILE语句从一个文本文件中以很高的速度读入一个表中.如果指定LOCAL关键词,从客户主机读文件.如果LOCAL没指定,文件必须位于服务器上.(LOCAL在MySQL3.22. ...
- bootstrap-table 表头和内容对不齐
问题: bootstrap-table.js 找到 BootstrapTable.prototype.resetView if (this.options.showHeader && ...
- 新安装的wampserver怎么使用本机已有的mysql作为数据库
一般在一台没有安装mysql的机器上安装好wamp后,能够直接在wamp的phpMyAdmin中打开集成的mysql并设置用户信息. 而假设之前已经安装配置好mysql(实usernamepasswo ...
- cmd执行调用打开文件
Process p = new Process();//新进程 p.StartInfo.FileName = "cmd.exe";//打开cmd程序 p.StartInfo.Use ...
- Makefileeasy犯错的语法
1.引言 近期学习android的Build系统,接触最多的自然就是Makefile语法.发现非常多easy出错的地方,不避开这些错误语法没法真正了解Makefile的内涵.以下就介绍遇到的一些让人困 ...
- ASP.NET MVC2 Web项目中公用类库的问题
ASP.NET WEB窗体 网站中,加入公用类文件的话,系统会很自动并殷勤的问你,说要不要把它存放在文件夹 App_Code 里.一旦加入,全站都可以很方便地加以使用,一点问题没有. 这种习以为常的方 ...
- C++派生类中如何初始化基类对象(五段代码)
今天收到盛大的面试,问我一个问题,关于派生类中如何初始化基类对象,我在想派生类对于构造函数不都是先构造基类对象,然后在构造子类对象,但是如果我们在成员初始化列表先初始化派生类的私有成员,在函数内去调用 ...