题解 | #放苹果#
放苹果
https://www.nowcoder.com/practice/bfd8234bb5e84be0b493656e390bdebf
import java.util.Scanner fun main(args: Array<String>) { val read = Scanner(System.`in`) val res1 = read.nextLine().split(' ').map { it.toInt() } val m = res1[0] val n = res1[1] solution(m, n) println(solution(m, n)) } fun solution(m: Int, n: Int): Int { return when { m == 0 || n == 1 -> 1 m < n -> solution(m, m) else -> solution(m - n, n) + solution(m, n - 1) } }