尝试构造一个数列$a{n}$,该数列就是最佳的选择尝试扔鸡蛋的楼层数序列。任选一个楼层,如果破了,就从该项的前一项开始往上逐一的选择楼层尝试。如果没破,没关系,该数列的特点就是保证代价相同【每判断一次,浪费掉一次尝试机会】,即$a_n-a_{n-1}= a_{n-1}-a_{n-2}-1 = a_1-(n-1)$。
现在来分析数列的特点。这是一个二阶等差数列,设总楼层是$m$, 容易得到,$a_n = n a_1 - 1/2 (n-1)n$, $1<=n<a_1$, 最后一项 $a_n$,满足关系:$a_n<m<a_{n+1}$, 于是 $1<=n<\frac{1}{2} \sqrt{8 m+1}-\frac{1}{2} $,即 $1<=n<=floor(\sqrt{2 m}-\frac{1}{2}} $
================
计算得知,该二阶等差数列的首项$a_1 = floor( \sqrt{2 m}-\frac{1}{2}) +1$
- Table[{m,aa=First[Sort[{a,n}/.List@ToRules[Reduce[1<=n<=a&&1<a&&n a -n (n-1)/2<m&&(n+1)a -n (n+1)/2>=m,{n,a},Integers]]]],Table[k aa[[1]] -k (k-1)/2,{k,aa[[2]]}]},{m,3,100}]//Column
复制代码
{3,{2,1},{2}}
{4,{3,1},{3}}
{5,{3,1},{3}}
{6,{3,2},{3,5}}
{7,{4,1},{4}}
{8,{4,2},{4,7}}
{9,{4,2},{4,7}}
{10,{4,3},{4,7,9}}
{11,{5,2},{5,9}}
{12,{5,2},{5,9}}
{13,{5,3},{5,9,12}}
{14,{5,3},{5,9,12}}
{15,{5,4},{5,9,12,14}}
{16,{6,3},{6,11,15}}
{17,{6,3},{6,11,15}}
{18,{6,3},{6,11,15}}
{19,{6,4},{6,11,15,18}}
{20,{6,4},{6,11,15,18}}
{21,{6,5},{6,11,15,18,20}}
{22,{7,3},{7,13,18}}
{23,{7,4},{7,13,18,22}}
{24,{7,4},{7,13,18,22}}
{25,{7,4},{7,13,18,22}}
{26,{7,5},{7,13,18,22,25}}
{27,{7,5},{7,13,18,22,25}}
{28,{7,6},{7,13,18,22,25,27}}
{29,{8,4},{8,15,21,26}}
{30,{8,4},{8,15,21,26}}
{31,{8,5},{8,15,21,26,30}}
{32,{8,5},{8,15,21,26,30}}
{33,{8,5},{8,15,21,26,30}}
{34,{8,6},{8,15,21,26,30,33}}
{35,{8,6},{8,15,21,26,30,33}}
{36,{8,7},{8,15,21,26,30,33,35}}
{37,{9,5},{9,17,24,30,35}}
{38,{9,5},{9,17,24,30,35}}
{39,{9,5},{9,17,24,30,35}}
{40,{9,6},{9,17,24,30,35,39}}
{41,{9,6},{9,17,24,30,35,39}}
{42,{9,6},{9,17,24,30,35,39}}
{43,{9,7},{9,17,24,30,35,39,42}}
{44,{9,7},{9,17,24,30,35,39,42}}
{45,{9,8},{9,17,24,30,35,39,42,44}}
{46,{10,6},{10,19,27,34,40,45}}
{47,{10,6},{10,19,27,34,40,45}}
{48,{10,6},{10,19,27,34,40,45}}
{49,{10,6},{10,19,27,34,40,45}}
{50,{10,7},{10,19,27,34,40,45,49}}
{51,{10,7},{10,19,27,34,40,45,49}}
{52,{10,7},{10,19,27,34,40,45,49}}
{53,{10,8},{10,19,27,34,40,45,49,52}}
{54,{10,8},{10,19,27,34,40,45,49,52}}
{55,{10,9},{10,19,27,34,40,45,49,52,54}}
{56,{11,6},{11,21,30,38,45,51}}
{57,{11,7},{11,21,30,38,45,51,56}}
{58,{11,7},{11,21,30,38,45,51,56}}
{59,{11,7},{11,21,30,38,45,51,56}}
{60,{11,7},{11,21,30,38,45,51,56}}
{61,{11,8},{11,21,30,38,45,51,56,60}}
{62,{11,8},{11,21,30,38,45,51,56,60}}
{63,{11,8},{11,21,30,38,45,51,56,60}}
{64,{11,9},{11,21,30,38,45,51,56,60,63}}
{65,{11,9},{11,21,30,38,45,51,56,60,63}}
{66,{11,10},{11,21,30,38,45,51,56,60,63,65}}
{67,{12,7},{12,23,33,42,50,57,63}}
{68,{12,7},{12,23,33,42,50,57,63}}
{69,{12,8},{12,23,33,42,50,57,63,68}}
{70,{12,8},{12,23,33,42,50,57,63,68}}
{71,{12,8},{12,23,33,42,50,57,63,68}}
{72,{12,8},{12,23,33,42,50,57,63,68}}
{73,{12,9},{12,23,33,42,50,57,63,68,72}}
{74,{12,9},{12,23,33,42,50,57,63,68,72}}
{75,{12,9},{12,23,33,42,50,57,63,68,72}}
{76,{12,10},{12,23,33,42,50,57,63,68,72,75}}
{77,{12,10},{12,23,33,42,50,57,63,68,72,75}}
{78,{12,11},{12,23,33,42,50,57,63,68,72,75,77}}
{79,{13,8},{13,25,36,46,55,63,70,76}}
{80,{13,8},{13,25,36,46,55,63,70,76}}
{81,{13,8},{13,25,36,46,55,63,70,76}}
{82,{13,9},{13,25,36,46,55,63,70,76,81}}
{83,{13,9},{13,25,36,46,55,63,70,76,81}}
{84,{13,9},{13,25,36,46,55,63,70,76,81}}
{85,{13,9},{13,25,36,46,55,63,70,76,81}}
{86,{13,10},{13,25,36,46,55,63,70,76,81,85}}
{87,{13,10},{13,25,36,46,55,63,70,76,81,85}}
{88,{13,10},{13,25,36,46,55,63,70,76,81,85}}
{89,{13,11},{13,25,36,46,55,63,70,76,81,85,88}}
{90,{13,11},{13,25,36,46,55,63,70,76,81,85,88}}
{91,{13,12},{13,25,36,46,55,63,70,76,81,85,88,90}}
{92,{14,9},{14,27,39,50,60,69,77,84,90}}
{93,{14,9},{14,27,39,50,60,69,77,84,90}}
{94,{14,9},{14,27,39,50,60,69,77,84,90}}
{95,{14,9},{14,27,39,50,60,69,77,84,90}}
{96,{14,10},{14,27,39,50,60,69,77,84,90,95}}
{97,{14,10},{14,27,39,50,60,69,77,84,90,95}}
{98,{14,10},{14,27,39,50,60,69,77,84,90,95}}
{99,{14,10},{14,27,39,50,60,69,77,84,90,95}}
{100,{14,11},{14,27,39,50,60,69,77,84,90,95,99}} |