1

你需要 100 磅的鸟食。约翰的包可以承载 15 磅,马克的包可以承载 25 磅。两个人都必须贡献完全相同的总金额。每个人必须进行的最少旅行次数是多少?

我已经使用方程组计算了这个。

15x + 25y = 100 15x - 25y = 0

这等于:John 将有 3.33 次行程,而 Mark 将有 2 次行程。只有一个问题:你不能有 1/3 的行程。

正确答案是:约翰要走 5 趟(75 磅),马克要走 3 趟(75 磅)。

你怎么计算这个?有没有可以做到这两层的excel公式?

4

2 回答 2

1

假设您将 A1 所需的总鸟食量以及约翰和马克的袋子限制分别放在 B1 和 B2 中,那么这个公式在 C1 中:

=MATCH(TRUE,INDEX(2*ROW(INDIRECT("1:100"))*LCM($B$1:$B$2)>=$A$1,,),0)*LCM($B$1:$ B$2)/B1

将给出约翰所需的最少旅行次数。将此公式复制到 C2 将为 Mark 提供相同的结果。

请注意部分中的 100:

行(间接(“1:100”))

是任意选择的,并且将给出正确的结果,前提是 John 和 Mark 都不需要进行超过两倍的旅行次数,即 200。显然,如果您认为有必要,您可以修改此值(理论上限制为 2^20) .

问候

于 2014-08-31T10:01:12.263 回答
1
  • Since John and Mark need to carry the same total amount of bird feed, what they will carry has to be a multiple of the least common multiple.
  • Since they both carry that amount the total amount will always be an even multiple of the LCM.
  • So find the least even multiple of the LCM that is larger than 100. And calculate the number of trips John and Mark will have to take from that.

For John:

CEILING(100/(2*LCM(15; 25));1)*LCM(15;25)/15

For Mark:

CEILING(100/(2*LCM(15; 25));1)*LCM(15;25)/25
于 2014-08-31T10:43:24.847 回答