[백준/파이썬] 11466번 풀이

업데이트:



문제 정보


풀이

문제

Alex is fond of origami — Japanese art of paper folding. Most origami designs start with a square sheet of paper. Alex is going to make a present for his mother. Present’s design requires three equal square sheets of paper, but Alex has only one rectangular sheet. He is able to cut out squares of this sheet, but their sides should be parallel to the sides of the sheet. Help Alex to determine the maximum possible size of the paper squares he is able to cut out.

입력 요약
The single line of the input file contains two integers h and w — the height and the width of the sheet of paper (1 ≤ h, w ≤ 1000).

출력 요약
Output a single real number — the maximum possible length of the square side. It should be possible to cut out three such squares of h × w sheet of paper, so that their sides are parallel to the sides of the sheet. …

코드

a,b=tuple(sorted(map(int, input().split())))
print(max(min(b/3,a), min(a,b)/2))

설명

핵심은 구현 관점에서 Alex is fond of origami — Japanese art of paper folding. Most origami designs start with a square sheet of paper. …를 만족하도록 로직을 구성하는 것입니다.

코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.

경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.



이런 주제는 어떠신가요?

비슷한 난이도와 유형의 문제를 이어서 보면 풀이 감각을 더 빠르게 잡기 좋습니다.

댓글남기기