PS/Baekjoon Online Judge

[백준 06162] Superlatives [Python]

kimyoungrok 2024. 7. 17. 01:14
728x90

문제

Typically, droughts are classified into “abnormally dry”, “moderate drought”, “severe drought”, “extreme drought”, and “exceptional drought”. The current drought is so “exceptional” in most of California that there have been discussions of adding one or more steps to the scale. But really, that will only delay the problem. Any system of discrete labels is not completely scalable. As computer scientists, you know that the answer is to build a naming system that allows you to just add more and more syllables. So how about “mega drought”, “mega mega drought”, “mega mega mega drought”, and so on? You can extend it arbitrarily. Here, you’ll write a program that finds the right number of “mega” to add.

You will be given two numbers: the amount of rain that was expected, and the amount of rain that actually occurred. If the former is less than the latter, we have no drought. If the expected rain is more than the actual rain, but not by a factor of more than 5, we just have a “drought”. If the expected rain is more by a factor of strictly more than 5, but not by a factor of more than 25, we have a “mega drought”. If it is more by a factor of strictly more than 25, but not by a factor more than 125, we have a “mega mega drought”. And so on — for each factor of 5, you add another “mega”.

입력

The first line is the number K of input data sets, followed by the K data sets, each of the following form:

Each data set has two integer numbers 0 ≤ E, A ≤ 1, 000, 000, with A > 0, the expected and actual amount of rain.

출력

For each data set, output “Data Set x:” on a line by itself, where x is its number.

Then output a string describing the type of drought that is going on (“no drought”, “drought”, “mega drought”, “mega mega drought”, etc.).

Each data set should be followed by a blank line.


풀이

예상 강수량과 실제 강수량을 비교해 예상 강우량이 실제 강우량보다 5배 넘을때마다 "mega" 을 추가로 출력하는 문제다.

문제에서는 예상 강우량이 실제 강우량 미만인 경우에만 “no drought”라고 하지만, 예제 1을 통해 두 값이 일치하는 경우에도 “no drought”으로 처리해야 한다.

실제 강우량이 예상 강우량보다 커질 때까지 5배씩 곱해주어 "mega"의 갯수를 세어주자.

만약 cnt가 0이라면 “no drought”이고 0보다 크다면 "meaa " 를 붙여주면 된다.


소스코드

보기


출처

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

728x90