본문 바로가기

Algorithm/Math

(C++) - 백준(BOJ) 6696 : Too Much Water

반응형

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

 

6696번: Too Much Water

Fred Mapper is a real estate agent in Prague. Many foreign delegates participating in NATO Summit ask him to find some house for them, because they want to rent it during their stay in Prague. Some even plan to stay here for a longer time after the Summit

www.acmicpc.net

수학 문제였습니다.

📕 풀이방법

📔 입력 및 초기화

 1. PI를 정의합니다. 시간당 물이 50평방미터씩 차지하므로 COVER_AREA를 정의해줍니다. 2. while loop를 수행합니다.부동산의 x, y좌표 x, y와 시간 hour, 그 좌표로 반원의 넓이를 저장할 propertyArea를 선언해줍니다.

📔 풀이과정

원점과 부동산의 거리를 구하고 그 영역을 반원의 넓이가 채울 때 시간을 구하면 됩니다.

📔 정답출력

형식에 따라 출력해줍니다.


📕 Code

#include <bits/stdc++.h>
#define PI 3.14159265359
#define COVER_AREA 50
using namespace std;
int main(){
    while(1){
        int hour = 0;
        double x, y, propertyArea;
        cin >> x >> y;
        if(!x && !y) break;
        propertyArea = (x * x + y * y) * PI / 2;
        hour = ceil(propertyArea / COVER_AREA);
        cout << "The property will be flooded in hour " <<  hour << ".\n";
    }
}