본문 바로가기

Algorithm/Math

(C++) - 백준(BOJ) 15610 : Abbey Courtyard

반응형

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

 

15610번: Abbey Courtyard

Bath’s annual Christmas market runs from the 23rd of November 2017 until the 10th of December 2017. During this time, the market will occupy the entire square courtyard of Bath Abbey. To brighten things up at night, a single long strand of cheerful festi

www.acmicpc.net

sqrt함수를 사용해보는 문제였습니다.

📕 풀이방법

📔 입력 및 초기화

정사각형의 평방미터를 의미하는 변수 square를 선언 후 입력받습니다.

 

📔 풀이과정

정사각형의 면적은 가로 * 세로입니다. 가로와 세로길이가 같기 때문에 제곱근을 구해주면 한 변의 길이가 나옵니다. 

 

📔 정답출력

한 변의 길이 * 4를 소수점 8번째자리까지 출력해줍니다.


📕 Code

#include <bits/stdc++.h>
using namespace std;
double square;
int main(){
    cin >> square;
    printf("%.8f",sqrt(square) * 4);
}