Advertisement
konchin_shih

期中考抽獎

Dec 12th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<vector>
  4. #include<random>
  5. #include<functional>
  6. using namespace std;
  7. main() {
  8.     string str = "FDforces Round #1 (Div. 1)";
  9.     auto seed = hash<string>()(str);
  10.     mt19937 mt(seed);
  11.     vector<int> participant{4, 5, 7, 8, 9, 10};
  12.     random_shuffle(participant.begin(), participant.end(), [&mt](int x) {
  13.         uniform_int_distribution<> dis(0, x - 1);
  14.         return dis(mt);
  15.     });
  16.     auto pick = bind(uniform_int_distribution<>(0, participant.size() - 1), mt);
  17.     cout << participant[pick()] << endl;
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement