Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3.  
  4. uint32_t xor128(void) {
  5.   static uint32_t x = 123456789;
  6.   static uint32_t y = 362436069;
  7.   static uint32_t z = 521288629;
  8.   static uint32_t w = 88675123;
  9.   uint32_t t;
  10.   t = x ^ (x << 11);  
  11.   x = y; y = z; z = w;  
  12.   return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
  13. }
  14.  
  15. using namespace std;
  16.  
  17. const int N = 1000000;
  18. int result[N];
  19. int meld_prob[3] = { 10, 7, 5 };
  20. int meld_target[3] = { 12, 12, 6 };
  21.  
  22. int main() {
  23.   for (int i = 0; i < N; i++) {
  24.     int meld = 0;
  25.     for (int j = 0; j < 3; j++) {
  26.       int success = 0;
  27.       while (true) {
  28.     meld++;
  29.     if (xor128() % 100 < meld_prob[j]) {
  30.       success++;
  31.       if (success >= meld_target[j]) break;
  32.     }
  33.       }
  34.     }
  35.     result[i] = meld;
  36.   }
  37.   sort(result, result + N);
  38.   cout << "80 percentile: " << (18 + result[N * 80 / 100]) << endl;
  39.   cout << "90 percentile: " << (18 + result[N * 90 / 100]) << endl;
  40.   cout << "95 percentile: " << (18 + result[N * 95 / 100]) << endl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement