Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Tomasz Nitsch 2B 15
- #include <iostream>
- #include <algorithm>
- #include <ctime>
- #include <stdlib.h>
- #include <climits>
- #include <set>
- #include <random>
- using namespace std;
- int main()
- {
- random_device rd;
- mt19937_64 eng(rd());
- uniform_int_distribution<unsigned long long> distr;
- ios_base::sync_with_stdio(false);
- srand(time(0));
- long long n, m, min_ = LLONG_MAX, i = 0;
- cin >> n >> m;
- int num;
- set<long long> lotto;
- while(true)
- {
- lotto.clear();
- while(lotto.size() != m)
- {
- num = distr(eng) % n + 1;
- if(num < min_)
- min_ = num;
- lotto.insert(num);
- cout << num << " ";
- }
- cout << "\t" <<min_ <<" " << i << endl;
- if(min_ == 1)
- {
- cout << endl << endl << (float) 1/((i+1)*n) * 100 << "%";
- return 0;
- }
- i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement