2591. Distribute Money to Maximum Children Easy
1/**
2 * [2591] Distribute Money to Maximum Children
3 *
4 * You are given an integer money denoting the amount of money (in dollars) that you have and another integer children denoting the number of children that you must distribute the money to.
5 * You have to distribute the money according to the following rules:
6 *
7 * All money must be distributed.
8 * Everyone must receive at least 1 dollar.
9 * Nobody receives 4 dollars.
10 *
11 * Return the maximum number of children who may receive exactly 8 dollars if you distribute the money according to the aforementioned rules. If there is no way to distribute the money, return -1.
12 *
13 * <strong class="example">Example 1:
14 *
15 * Input: money = 20, children = 3
16 * Output: 1
17 * Explanation:
18 * The maximum number of children with 8 dollars will be 1. One of the ways to distribute the money is:
19 * - 8 dollars to the first child.
20 * - 9 dollars to the second child.
21 * - 3 dollars to the third child.
22 * It can be proven that no distribution exists such that number of children getting 8 dollars is greater than 1.
23 *
24 * <strong class="example">Example 2:
25 *
26 * Input: money = 16, children = 2
27 * Output: 2
28 * Explanation: Each child can be given 8 dollars.
29 *
30 *
31 * Constraints:
32 *
33 * 1 <= money <= 200
34 * 2 <= children <= 30
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/distribute-money-to-maximum-children/
40// discuss: https://leetcode.com/problems/distribute-money-to-maximum-children/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn dist_money(money: i32, children: i32) -> i32 {
46 0
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_2591() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.