翻译
令 m>n>1 为正整数. 一个集合含有 m 个给定的实数. 我们从中选取任意 n 个数, 记作 a_1, a_2, \dotsc, a_n, 并提问: 是否 a_1<a_2<\dotsb < a_n 正确? 证明: 我们可以最多问 n!-n^2+2n-2+m(n-1)(1+\lfloor \log_{n} m \rfloor)-m 个问题,将所有的 m 个数排序.
We can find the order of the first n numbers n!-1 questions,
looking at all possible orderings but one.
我们可通过查看除1以外的所有可能的顺序,找出前n个数n!-1个问题的顺序.
Suppose we have found the relative order of the first k numbers
and let us find the relative order of first k+1 numbers.
假设我们已找到前k个数的相对顺序,让我们来找出前k+1个数的相对顺序.
Suppose we have a_1<a_2<\dotsb<a_k
and let us find where a_{k+1} fits.
假设有a_1<a_2<\dotsb<a_k,让我们找出a_{k+1}应该放在哪里.
We use the following {\it binary search}:
pick n-1 numbers among 1,2,\dotsc,k that divide the interval [1,k]
most equally.
利用下面的\textbf{二分法搜索(binary search)}:在1,2,\dotsc,k之间选取n-1个数等分区间[1,k].
(This is achieved by taking the numbers
a_{\left\lfloor \frac{k}{n}\right\rfloor},a_{\left\lfloor \frac{2k}{n}\right\rfloor},\ldots , a_{\left\lfloor \frac{(n-1)k}{n}\right\rfloor}).
(这可通过取数字
a_{\left\lfloor \frac{k}{n}\right\rfloor},a_{\left\lfloor \frac{2k}{n}\right\rfloor},\ldots , a_{\left\lfloor \frac{(n-1)k}{n}\right\rfloor}来实现).
We can find the relative order of a_{k+1} and these numbers by at most n-1 questions.
我们最多可通过n-1次提问找出a_{k+1}和这些数的相对顺序.
Indeed, for 1\leqslant j\leqslant n-1, let q_i be ``Is it true that
a_{\left\lfloor \frac{k}{n}\right\rfloor}<\ldots <aa_{\left\lfloor \frac{ik}{n}\right\rfloor} <a_{k+1}<a_{\left\lfloor \frac{(i+1)k}{n}\right\rfloor}<\ldots <a_{\left\lfloor \frac{(n-1)k}{n}\right\rfloor}?''
实际上, 对于1\leqslant j\leqslant n-1, 令q_i为``
a_{\left\lfloor \frac{k}{n}\right\rfloor}<\ldots <aa_{\left\lfloor \frac{ik}{n}\right\rfloor} <a_{k+1}<a_{\left\lfloor \frac{(i+1)k}{n}\right\rfloor}<\ldots <a_{\left\lfloor \frac{(n-1)k}{n}\right\rfloor}成立么?''
Then we find an i such that
a_{\left\lfloor \frac{ik}{n}\right\rfloor}<a_{k+1}<a_{\left\lfloor \frac{(i+1)k}{n}\right\rfloor}.
那么我们找到 i使得
a_{\left\lfloor \frac{ik}{n}\right\rfloor}<a_{k+1}<a_{\left\lfloor \frac{(i+1)k}{n}\right\rfloor}.
Therefore, by at most n-1 questions we reduce the length of the interval of searching
from k to at most \left\lceil \frac{k}{n}\right\rceil, where \lceil x\rceil
is the least integer number not less than x.
因此,我们最多可通过n-1个问题,使搜索的区间长度从k减小到最多是\left\lceil \frac{k}{n}\right\rceil,其中\lceil x\rceil为不小于x的最小整数.
We repeat this binary search until we find exactly the position of a_{k+1}
(that is, the interval of searching is 1 or 0).
我们重复这个二分法搜索,直到找出a_{k+1}的确切位置.
(即搜索间隔为1或0).
Now if k\leqslant n^j, then after i steps the interval will be at most n^{j-i},
so we need at most j=\lceil \log _n k\rceil steps to insert a_{k+1} into the sequence.
现在,如果k\leqslant n^j,那么在i步之后,间隔最多为n^{j-i},因此我们最多需要j=\lceil \log _n k\rceil步来将a_{k+1}插入数列中.
Therefore, the number of questions needed is at most
n!-1+(n-1)(\lceil \log_n(n+1)\rceil+\ldots +\lceil \log_n(m-1)\rceil).
因此,所需的提问次数最多为
n!-1+(n-1)(\lceil \log_n(n+1)\rceil+\ldots +\lceil \log_n(m-1)\rceil).
All we need to do is to evaluate this number:
suppose that
n^k\leqslant m<n^{k+1}.
Then there are n^2-n numbers r for which
\lceil \log_n r\rceil=2, n^3-n^2 numbers for which
\lceil \log_n r\rceil=3, and so on until we have m-1-n^k numbers r for which
\lceil \log_n r\rceil=k+1.
我们需要做的就是计算这个数字:设
n^k\leqslant m<n^{k+1}.
那么有n^2-n个数r满足\lceil \log_n r\rceil=2, 有n^3-n^2个数满足\lceil \log_n r\rceil=3等等,直到我们有m-1-n^k个数r满足
\lceil \log_n r\rceil=k+1.
Therefore the sum is
\begin{align*} n!-1+(n-1)(2(n^2-n)+3(n^3-n^2)+\dotsb +k(n^k-n^{k-1})+(k+1)(m-1-n^k)) \\ =n!-1+(n-1)((k+1)(m-1)-n^k-n^{k-1}-\dotsb -n^2-2n). \end{align*}
Because n^{k+1}>m,
n^k+n^{k-1}+\dotsb +n^2+2n=\frac{n^{k+1}-1}{n-1}+n-1 \geqslant \frac{m}{n-1}+n-1.
Hence our sum is at most
\begin{align*} n!-1+(n-1)\left((k+1)(m-1)-\frac{m}{n-1}-n+1\right) \\ = n!-n^2+2n-2+(n-1)(\lfloor \log_n m\rfloor+1)m-m, \end{align*}
as desired.
因此和为
\begin{align*} n!-1+(n-1)(2(n^2-n)+3(n^3-n^2)+\dotsb +k(n^k-n^{k-1})+(k+1)(m-1-n^k)) \\ =n!-1+(n-1)((k+1)(m-1)-n^k-n^{k-1}-\dotsb -n^2-2n). \end{align*}
由于n^{k+1}>m,
n^k+n^{k-1}+\dotsb +n^2+2n=\frac{n^{k+1}-1}{n-1}+n-1 \geqslant \frac{m}{n-1}+n-1.
因此我们的和最多为
\begin{align*} n!-1+(n-1)\left((k+1)(m-1)-\frac{m}{n-1}-n+1\right) \\ = n!-n^2+2n-2+(n-1)(\lfloor \log_n m\rfloor+1)m-m, \end{align*}
得证.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】博客园携手 AI 驱动开发工具商 Chat2DB 推出联合终身会员
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET 依赖注入中的 Captive Dependency
· .NET Core 对象分配(Alloc)底层原理浅谈
· 聊一聊 C#异步 任务延续的三种底层玩法
· 敏捷开发:如何高效开每日站会
· 为什么 .NET8线程池 容易引发线程饥饿
· 一个适用于 .NET 的开源整洁架构项目模板
· .NET 9.0 使用 Vulkan API 编写跨平台图形应用
· 终于决定:把自己家的能源管理系统开源了!
· [.NET] 使用客户端缓存提高API性能
· AsyncLocal的妙用
2014-07-25 LaTeX技巧012:LaTeX 插图加载宏包