2025 AIME II 第 8 题

先试着解答 2025 AIME II 第 8 题,然后核对你的答案与精心整理的解答,解答来自 LIVE by Po-Shen Loh。你也可以参加完整限时模拟考试、查看全部 2025 AIME II 解答,或核对答案

所有题目均经美国数学协会(MAA)官方合法授权使用。

8.

Silas 有无限多枚 11 分硬币、1010 分硬币和 2525 分硬币。他想找出若干硬币,使总价值为 NN 分,其中 NN 是正整数。他使用所谓的 贪心算法:每一步都选择不会使当前总价值超过 NN 的最大面值硬币。例如,为了凑 4242 分,Silas 会选择一枚 2525 分硬币、一枚 1010 分硬币,然后选择 7711 分硬币。然而,这组 99 枚硬币比必要数量更多;事实上, 选择 441010 分硬币和 2211 分硬币也能得到同样总价值 4242 分,且只用 66 枚硬币。

一般来说,若不存在另一组 11 分、1010 分和 2525 分硬币,能用严格更少的硬币数凑出 NN 分,则称贪心算法对该 NN 成功。求 1110001000(含端点)之间使贪心算法成功的 NN 的个数。

From an unlimited supply of 11-cent coins, 1010-cent coins, and 2525-cent coins, Silas wants to find a collection of coins that has a total value of NN cents, where NN is a positive integer. He uses the so-called greedy algorithm, successively choosing the coin of greatest value that does not cause the value of his collection to exceed N.N. For example, to get 4242 cents, Silas will choose a 2525-cent coin, then a 1010-cent coin, then 77 11-cent coins. However, this collection of 99 coins uses more coins than necessary to get a total of 4242 cents; indeed, choosing 44 1010-cent coins and 22 11-cent coins achieves the same total value with only 66 coins.

In general, the greedy algorithm succeeds for a given NN if no other collection of 11-cent, 1010-cent, and 2525-cent coins gives a total value of NN cents using strictly fewer coins than the collection given by the greedy algorithm. Find the number of values of NN between 11 and 10001000 inclusive for which the greedy algorithm succeeds.

答案:610
知识点:最优化钱币模运算分类讨论
难度评级:2990
解答:

在任意最优组合中,最多有 99 枚一分硬币(十枚一分可换成一枚十分),最多有 44 枚十分硬币 (五枚十分可换成两枚二十五分),所以十分和一分硬币的总价值最多为 4949 分。因此一个最优组合使用 q=N/25q = \lfloor N/25 \rfloor 枚二十五分硬币,和贪心算法一样,或使用 q1q - 1 枚二十五分硬币。 对于只由十分和一分硬币组成的金额 vv,最佳硬币数为 f(v)=v/10+(vmod10)f(v) = \lfloor v/10 \rfloor + (v \bmod 10),这正是贪心算法处理余数的方式。

r=Nmod25r = N \bmod 25。贪心算法使用 q+f(r)q + f(r) 枚硬币,唯一的竞争方案使用 (q1)+f(r+25)(q - 1) + f(r + 25) 枚硬币(当 q1q \ge 1 时可行),所以贪心算法失败当且仅当 f(r+25)f(r)f(r + 25) \le f(r)。列表计算:对 r=0,,4r = 0, \ldots, 4f(r+25)=r+7>f(r)=rf(r+25) = r + 7 \gt f(r) = r;对 r=5,,9r = 5, \ldots, 9f(r+25)=r2rf(r+25) = r - 2 \le r;对 r=10,,14r = 10, \ldots, 14f(r+25)=r2>r9f(r+25) = r - 2 \gt r - 9;对 r=15,,19r = 15, \ldots, 19f(r+25)=r11r9f(r+25) = r - 11 \le r - 9;对 r=20,,24r = 20, \ldots, 24f(r+25)=r11>r18f(r+25) = r - 11 \gt r - 18。所以贪心算法失败恰好发生在 N25N \ge 25r{5,,9}{15,,19}r \in \{5, \ldots, 9\} \cup \{15, \ldots, 19\} 时。

1,,10001, \ldots, 1000 中,每个模 2525 的余数类都有 4040NN,所以上述 1010 个余数给出 400400 个值,其中小于 25251010 个值不计入失败(此时 q=0q = 0)。 因而贪心算法失败于 390390 个值,成功于 1000390=6101000 - 390 = 610 个值。

In any optimal collection there are at most 99 pennies (ten pennies could become a dime) and at most 44 dimes (five dimes could become two quarters), so its dimes and pennies are worth at most 4949 cents. Hence an optimal collection uses either q=N/25q = \lfloor N/25 \rfloor quarters, like greedy, or q1q - 1 quarters. For an amount vv made only of dimes and pennies, the best count is f(v)=v/10+(vmod10),f(v) = \lfloor v/10 \rfloor + (v \bmod 10), which is what greedy does on the remainder.

Let r=Nmod25.r = N \bmod 25. Greedy uses q+f(r)q + f(r) coins, and the only rival uses (q1)+f(r+25)(q - 1) + f(r + 25) coins (possible when q1q \ge 1), so greedy fails exactly when f(r+25)f(r).f(r + 25) \le f(r). Tabulating: for r=0,,4,r = 0, \ldots, 4, f(r+25)=r+7>f(r)=r;f(r+25) = r + 7 \gt f(r) = r; for r=5,,9,r = 5, \ldots, 9, f(r+25)=r2r;f(r+25) = r - 2 \le r; for r=10,,14,r = 10, \ldots, 14, f(r+25)=r2>r9;f(r+25) = r - 2 \gt r - 9; for r=15,,19,r = 15, \ldots, 19, f(r+25)=r11r9;f(r+25) = r - 11 \le r - 9; for r=20,,24,r = 20, \ldots, 24, f(r+25)=r11>r18.f(r+25) = r - 11 \gt r - 18. So greedy fails exactly when N25N \ge 25 and r{5,,9}{15,,19}.r \in \{5, \ldots, 9\} \cup \{15, \ldots, 19\}.

Each residue class mod 2525 contains 4040 values of NN in 1,,1000,1, \ldots, 1000, so these 1010 residues give 400400 values, of which the 1010 values less than 2525 do not count (there q=0q = 0). Greedy fails for 390390 values and succeeds for 1000390=610.1000 - 390 = 610.

← 第 7 题#7
完整试卷

其他年份的第 8 题