Problem 2742 --Math Functions - Distance II

2742: Math Functions - Distance II

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $5$ 正确数量 $3$
裁判形式 特别裁判/Special Judge 我的状态 尚未尝试
难度 分类标签 STL

Distance II 

Your task is to calculate the distance between two n dimensional vectors x={x1,x2,...,xn} and y={y1,y2,...,yn}. 

The Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and the Euclidean distance.

It can be the Manhattan distance

where p=1. 

 It can be the Euclidean distance 

where p=2. 

Also, it can be the Chebyshev distance

where p=∞ 

Write a program which reads two n dimensional vectors x and y, and calculates Minkowski's distance where p=1,2,3,∞ respectively.

In the first line, an integer n is given. In the second and third line, x={x1,x2,...xn} and y={y1,y2,...yn} are given respectively. The elements in x and y are given in integers.
Print the distance where p=1,2,3 and ∞ in a line respectively. The output should not contain an absolute error greater than 10^-5.
3
1 2 3
2 0 4
4.000000
2.449490
2.154435
2.000000

1≤n≤100 

0≤xi,yi≤1000

推荐代码 查看2742 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] AOJ大管家 411601 2019-04-28 13:20:25
内存最少[$2204 $KB] AOJ大管家 411601 2019-04-28 13:20:25
第一AC AOJ大管家 332799 2018-11-27 23:19:37
第一挑战 AOJ大管家 332799 2018-11-27 23:19:37

赛题来源/所属竞赛 会津大学《C++ Programming I》 C++程序设计(入门)

竞赛编号 竞赛名称 竞赛时间 访问比赛