Advertisement
iStrzalka

Jak ktos chce sie pobawic

Oct 5th, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. //Tomasz Nitsch 2B 15
  2.  
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <ctime>
  6. #include <stdlib.h>
  7. #include <climits>
  8. #include <set>
  9. #include <random>
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. random_device rd;
  15. mt19937_64 eng(rd());
  16.  
  17. uniform_int_distribution<unsigned long long> distr;
  18.  
  19. ios_base::sync_with_stdio(false);
  20. srand(time(0));
  21. long long n, m, min_ = LLONG_MAX, i = 0;
  22. cin >> n >> m;
  23.  
  24. int num;
  25. set<long long> lotto;
  26.  
  27. while(true)
  28. {
  29. lotto.clear();
  30. while(lotto.size() != m)
  31. {
  32. num = distr(eng) % n + 1;
  33. if(num < min_)
  34. min_ = num;
  35. lotto.insert(num);
  36. cout << num << " ";
  37. }
  38.  
  39. cout << "\t" <<min_ <<" " << i << endl;
  40. if(min_ == 1)
  41. {
  42. cout << endl << endl << (float) 1/((i+1)*n) * 100 << "%";
  43. return 0;
  44. }
  45. i++;
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement