cs

https://www.hackerrank.com/challenges/weather-observation-station-19/problem?isFullScreen=true&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen 

 

Weather Observation Station 19 | HackerRank

Query the Euclidean Distance between two points and round to 4 decimal digits.

www.hackerrank.com


Consider P1 (a, b) and P2(a, b) to be two points on a 2D plane where (a, b) are the respective minimum and maximum values of Northern Latitude (LAT_N) and (c, d) are the respective minimum and maximum values of Western Longitude (LONG_W) in STATION.

Query the Euclidean Distance between points P1 and P2 and format your answer to display 4 decimal digits.

Input Format

The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.

 

[My Answer]

#가장 밖에 ROUND 걸어서 소수점
#SQRT로 제곱근 밖에써주고 
#POWER로 최대 - 최소의 제곱값 더해주고

SELECT 
ROUND(SQRT(POWER(MAX(LAT_N) - MIN(LAT_N), 2) +
		POWER(MAX(LONG_W) - MIN(LONG_W), 2)), 4) 
FROM STATION;

지난번에 맨해튼 거리 나올 때, 유클리드가 더 기본인데 왜 안 나오냐 했는데

 

안 나올 리가 없지.. 

수학공부하고싶은.. 

 

https://ko.wikipedia.org/wiki/%EC%9C%A0%ED%81%B4%EB%A6%AC%EB%93%9C_%EA%B1%B0%EB%A6%AC

 

유클리드 거리 - 위키백과, 우리 모두의 백과사전

유클리드 거리(Euclidean distance)는 두 점 사이의 거리를 계산할 때 흔히 쓰는 방법이다. 이 거리를 사용하여 유클리드 공간을 정의할 수 있으며, 이 거리에 대응하는 노름을 유클리드 노름(Euclidean n

ko.wikipedia.org

 

+ Recent posts