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 ...
随机推荐
- 当样式中存在!important时无法使用show()或hide() 2017-06-11 22:25 15人阅读 评论(0) 收藏
如果使用!important在你的样式中,比如display: none !important,此时就不能用show()了 但是我在查阅资料时发现有这样的解释, If using !important ...
- 爬虫系列(六) 用urllib和re爬取百度贴吧
这篇文章我们将使用 urllib 和 re 模块爬取百度贴吧,并使用三种文件格式存储数据,下面先贴上最终的效果图 1.网页分析 (1)准备工作 首先我们使用 Chrome 浏览器打开 百度贴吧,在输入 ...
- Bootstrap 表单控件状态(验证状态)
在制作表单时,不免要做表单验证.同样也需要提供验证状态样式,在Bootstrap框架中同样提供这几种效果.1..has-warning:警告状态(黄色)2..has-error:错误状态(红色)3.. ...
- linux根据进程名字杀死进程
ps -ef | grep procedure_name | grep -v grep | awk '{print $2}' | xargs kill -9 Linux Shell脚本实现根据进程名杀 ...
- 合并目录中的txt文件
txt 文件 合并 并 按章节 分隔 # -*- coding: utf8 -*- import os result_name = 'result.txt' def resplit_txt_in_fo ...
- (33)Spring Boot 监控和管理生产环境【从零开始学Spring Boot】
[本文章是否对你有用以及是否有好的建议,请留言] spring-boot-actuator模块提供了一个监控和管理生产环境的模块,可以使用http.jmx.ssh.telnet等拉管理和监控应用.审计 ...
- Java上使用Lombok插件简化Getter、Setter方法
Maven引入依赖: <dependencies> <dependency> <groupId>org.projectlombok</groupId> ...
- 公众号和app和web都是客户端,都可以对接一个后台
1.公众号和app和web都是客户端,都可以对接一个后台 2.域名中包含端口号吗?:不包括,不包括 3.目前在IIS服务器上搭建了一个网站,域名也申请了,可是80端口不能使用,可以使用8000,每次访 ...
- Js计算指定日期
function DateAdd(interval,number,date) { /* * 功能:实现VBScript的DateAdd功能. * 参数:interval,字符串表达式,表示要添加的时间 ...
- android 细节之An internal error occurred during: "Launching New_configuration".
今天在导入公司的一个小demo时候发现了一个非常有意思的错误. An internal error occurred during: "Launching New_configuration ...