Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cmath>
- #include<list>
- ...
- double prob(int n, int k, double p) {
- std::list<double> buf(n-1,0.0);
- buf.push_back(pow(p,n));
- for(int i=n; i<k; i++) {
- buf.push_back(buf.back()+(1-p)*pow(p,n)*(1-buf.front()));
- buf.pop_front();
- }
- return buf.back();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement