[백준] Alex Origami Squares (11466)(kotlin)

원본 문제

문제 설명

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.

Your answer should be precise up to three digits after the decimal point.

테스트 케이스

입력 출력
210 297 105.0
250 100 83.333333

문제 풀이1

import kotlin.math.max

fun main(args: Array<String>) = println(
    readLine()!!
        .split(" ")
        .map { it.toInt() }
        .let {
            val (max, min) = it.sortedDescending()
            val inARow = if (max / 3 < min) max / 3.toDouble() else min.toDouble()
            val twoLine = min / 2.toDouble()

            String.format("%.3f",max(inARow, twoLine))
        }
)