Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 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.  
  20. int main() {
  21.   for (int i = 0; i < N; i++) {
  22.     int success = 0;
  23.     int meld = 0;
  24.     while (true) {
  25.       meld++;
  26.       if (xor128() % 100 < 17) {
  27.         success++;
  28.         if (success >= 12) break;
  29.       }
  30.     }
  31.     result[i] = meld;
  32.   }
  33.   sort(result, result + N);
  34.   cout << "80 percentile: " << (18 + result[N * 80 / 100]) << endl;
  35.   cout << "90 percentile: " << (18 + result[N * 90 / 100]) << endl;
  36.   cout << "95 percentile: " << (18 + result[N * 95 / 100]) << endl;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement