d*z 发帖数: 150 | 1
m为瓶的数目,N为楼的高度,当然
f(m,1)=1,f(1,N)=N.(100层一个瓶时应该是100次,而不是99次呀,
因为有可能在100层也不会摔碎)。
f(m,N)=min{f(m-1,k-1)+f(m,N-k)|k=2,...,N-1} | w*y 发帖数: 70 | 2 当m=2时,记f2(x)=f(2,x);
f2(x)=min{ max[(t-1), f(n-t)+1]| t=2,3,...,n-1}
f2(0)=0;
f2(1)=1;
f2(2)=1;
...
推出f2(100)=13.
其实13是对的,见下:
第一个瓶子层数/第二个瓶子层数/投掷次数 | a******t 发帖数: 100 | 3 perl script :
@history;
sub cal
{
my $n = shift @_;
my $m = shift @_;
my $a = $n;
return $history[$n][$m] if ($history[$n][$m] > 0);
return $a if ($m == 1);
return 10000 if ($m < 1);
return 1 if ($n == 1);
return 10000 if ($n < 1);
foreach my $k (2..$n-1)
{
my $b, $c;
$b = 1 + cal($k - 1, $m - 1);
$c = 1 + cal($n - $k, $m);
$b = $c if ($c > | h*l 发帖数: 19 | 4 Ok, a "strategy" is: within steps tried and
information obtained, what is/could_be the
next step so that it can/could lead objective".
Likewise, we can define "contional strategy"
(e.g. n-steps strategy) and "optimal strategy"
(e.g. maximum-information-gain strategy),
"guranteed-strategy" (no probabilistic betting)
Strategy is in general not a predetermined step-
"sequence" but a step "relation". A strategy
is still an "algorthim".
This problem is: Find a minimum integer n,
so there exsists a n- |
|