728x90

https://www.acmicpc.net/problem/3053

Code

최종 제출 코드

😢 택시 기하학과 유클리드 기하학을 검색한 후, 이해하고 풀면 되는 문제

😊 유클리드 기하학에서 반지름이 R인 원이 넓이'반지름*반지름*PI'이므로 Math.powMath.PI를 이용하여 풀었고,
택시 기하학에서 반지름이 R인 원의 넓이마름모와 같으므로, '밑변*높이*2'(직사각형 넓이*2라고 생각)로 풀어주면 된다.

Full Code (https://github.com/DasolPark/Dasol_JS_Algorithm/tree/master/Baekjoon)

// Taxi geometry(Euclid geometry)
 
// For submit
 
// const fs = require('fs');
// const input = parseInt(fs.readFileSync('/dev/stdin').toString().trim());
 
// For local test
const input = 1;
 
function Euclid(radius) {
return Math.pow(radius, 2) * Math.PI;
}
 
function taxi(radius) {
return Math.pow(radius, 2) * 2;
}
 
console.log(Euclid(input).toFixed(6));
console.log(taxi(input).toFixed(6));

+ Recent posts