bartekltg

asteroid reprocessing quality

Apr 24th, 2026 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <random>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     random_device rd;
  10.     mt19937 gen(rd());
  11.     constexpr int MAX = 100000000;
  12.  
  13.     bernoulli_distribution loss(0.2), quality(0.08), upQ(0.1);
  14.     int count =0;
  15.     int cycle =0;
  16.     for (int i=1; i<=MAX; i++){
  17.         int level=1;
  18.         cycle++;
  19.         while (!loss(gen)){
  20.             if (quality(gen)){
  21.                 level++;
  22.                 while (level<5 && upQ(gen)){
  23.                     level++;
  24.                 }
  25.                 if (level>=5){
  26.                     count++;
  27.                     break;
  28.                 }
  29.             }
  30.             cycle++;
  31.         }
  32.         if ((i)%100000==0){
  33.             cout<<i<<" "<<count<<" "<<count/(double)i<<" "<<cycle/(double)i<<" "<<endl;
  34.         }
  35.     }
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment