由买买提看人间百态

topics

全部话题 - 话题: 2qp
(共0页)
m*****r
发帖数: 84
1
来自主题: JobHunting版 - G's interview, 2 questions
It took a while to come up the following solution.Yep, it should be a PHD
qualify题目.
Let X be number of tosses. Let q = 1-p
First, if p = 1, then, clearly E(X) = m.
Suppose 0 < p < 1. We can calculate the expectation E(X) via conditioning
Let t_i be the result of the i-th toss
Consider using telescoping by observing that
E(X) = E(X|t_1 = H)p + (E(X)+1)q
E(X|t_1 = H) = E(X|t_1 = H,t_2 = H)p + (E(X)+2)q
E(X|t_1 = H,t_2 = H) = ... 阅读全帖
p****r
发帖数: 165
2
来自主题: Programming版 - store "" in c string
C code, not going to useC++:
char* P_dir;
P_dir = "D:\2QP\C_P\P Inputs";
at run time, the actual value of P_dir is:
P_dir = "D:2QPC_PP Inputs";
it ignored all the backslash "", how to keep the ""? Thanks
d***a
发帖数: 13752
3
来自主题: Programming版 - store "" in c string
用\\代替\,
P_dir = "D:\\2QP\\C_P\\P Inputs";
相关的概念是C escape sequence,
https://en.wikipedia.org/wiki/Escape_sequences_in_C
(共0页)