※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 15610번 문제인 Abbey Courtyard이다.
문제는 아래 링크를 확인하자.
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
이 문제는 주어진 long long인 정수 넓이의 정사각형 의 둘레의 길이를 구하는 문제이다.
계산에 제곱근이 들어가고, relative error(상대오차)가 최대 10^(-6)이여야한다는 점을 확인하고 풀자.
아래는 제출한 소스코드이다.
#include <iostream>
#include <cmath>
#include <iomanip>
using std::sqrt;
using std::cin;
using std::cout;
using std::setprecision;
int main()
{
double n;
cin >> n;
cout << setprecision(20) << 4*sqrt(n);
return 0;
}
728x90
'BOJ' 카테고리의 다른 글
[BOJ 20493 // C++] 세상은 하나의 손수건 (0) | 2021.01.24 |
---|---|
[BOJ 6603 // C++] 로또 (0) | 2021.01.23 |
[BOJ 1533 // C++] 길의 개수 (0) | 2021.01.21 |
[BOJ 13328 // C++] Message Passing (0) | 2021.01.20 |
[BOJ 12850 // C++] 본대 산책 2 (0) | 2021.01.19 |