回複:Quant麵試題:喝醉了(2.5星)

99

2f(n) = 2 + f(n-1) + f(n+1); when 0 f(0) = 0;
f(100) = 0;
f(n) = f(100-n);

==> 2f(50) = 2 + f(49) + f(51);
==> f(50) = 1 + f(49);
==> f(49) = 3 + f(48);
==> f(48) = 5 + f(47)
==> ...
==> f(n) = 1 + (50-n)*2 + f(n-1);
==> ...
==> f(1) = 99 + f(0) = 99;

請您先登陸,再發跟帖!