2014-03-20 01:57

题目:玩篮球投篮,有两种玩法:要么1投1中,要么3投两中。你单次投篮中的概率是p,那么对于不同的p,哪种玩法胜率更高?

解法:第一种总是胜率更高,可以列不等式算算,结果发现是个恒不等式。

代码:

 1 // 7.1 Suppose you're playing a basketball game, you have two choices:
 2 // A: one shot one hit
 3 // B: three shots two hits
 4 // For what probability of p would you choose A or B.
 5 // 
 6 // Answer:
 7 // P(A) = p;
 8 // P(B) = C(3, 2) * p * p * (1 - p);
 9 // if P(A) < P(B), p < 3 * p * p * (1 - p)
10 // 1 < 3 * p * (1 - p)
11 // 3 * p * p - 3 * p + 1 < 0
12 // There's no root for this equation, thus for any p, 1 > 3 * p * (1 - p)
13 // Thus for any p, p > 3 * p * (1 - p)
14 // P(A)> P(B), choosing A will always be better.
15 int main()
16 {
17     return 0;
18 }

 

相关文章:

  • 2021-10-10
  • 2021-12-07
  • 2021-10-17
  • 2021-11-21
  • 2021-09-27
  • 2021-05-22
  • 2021-05-31
  • 2021-07-01
猜你喜欢
  • 2021-05-26
  • 2021-08-21
  • 2021-12-19
  • 2021-12-24
  • 2021-08-24
  • 2021-10-18
  • 2022-01-05
相关资源
相似解决方案