Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <random>
- using namespace std;
- int main()
- {
- random_device rd;
- mt19937 gen(rd());
- constexpr int MAX = 100000000;
- bernoulli_distribution loss(0.2), quality(0.08), upQ(0.1);
- int count =0;
- int cycle =0;
- for (int i=1; i<=MAX; i++){
- int level=1;
- cycle++;
- while (!loss(gen)){
- if (quality(gen)){
- level++;
- while (level<5 && upQ(gen)){
- level++;
- }
- if (level>=5){
- count++;
- break;
- }
- }
- cycle++;
- }
- if ((i)%100000==0){
- cout<<i<<" "<<count<<" "<<count/(double)i<<" "<<cycle/(double)i<<" "<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment