Kattis - Different Distances
2024-08-28 22:30:23
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 ;
}
最新文章
- ACM提交结果简介
- 又踩.NET Core的坑:在同步方法中调用异步方法Wait时发生死锁(deadlock)
- repeater 根据输入 返回汉字
- Application Initialization Module for IIS 7.5
- cdr创建样式与样式集的方法
- 二级域名session 共享方案
- 使用Cloudera部署,管理Hadoop集群
- js中小数的操作及数字类型的验证
- CCNP第一天 Rip综合实验
- W5300E01-ARM 交叉编译器(Cross Compiler)用户手册
- python顶级执行代码
- java学习笔记 --- 条件,循环语句
- Python包和版本管理的最好工具----pipenv
- fiddler限制网速
- IP通信基础学习第六周(下)
- https笔记【转】
- eclipse如何导入jar包 BUILD PATH
- 浅析原生js模仿addclass和removeclass
- Linux和windows 查看程序、进程的依赖库的方法
- stl源码剖析 详细学习笔记 算法(2)
热门文章
- 系统和帮助-Linux基础知识
- tween.js缓动(补间动画)
- 邓_ PHP&#183;笔记(函数总结)
- What identity values you get with the @@IDENTITY and SCOPE_IDENTITY functions
- 教你 Shiro + SpringBoot 整合 JWT
- (22)Spring Boot 拦截器HandlerInterceptor【从零开始学Spring Boot】
- ZooKeeper搭建系列集 (这套很全,也很详细)
- 进入Material Design时代
- 【slighttpd】基于lighttpd架构的Server项目实战(6)—预备知识之Http
- APP漏洞自动化扫描专业评测报告(中篇)