Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <vector>
- #include <string>
- using namespace std;
- uint32_t x0, x1, a, b, c;
- const int basic = (1 << 31);
- uint32_t next() {
- int32_t t = x0 * a + x1 * b + c;
- x0 = x1;
- x1 = t;
- return (x1 << 1) >> 1;
- }
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int n, k;
- cin >> n >> k >> x0 >> x1 >> a >> b >> c;
- vector<int> ans(2 * k, 0);
- int q = 0;
- for (int i = 0; i < n; i++) {
- int x = next();
- ans[q] = x;
- q++;
- if (q == k) {
- nth_element(ans.begin(), ans.begin() + k, ans.end());
- q = 0;
- }
- }
- nth_element(ans.begin(), ans.begin() + k, ans.end());
- vector<int> res(k);
- for (int i = k; i < 2 * k; i++)
- res[i - k] = ans[i];
- sort(res.begin(), res.end());
- reverse(res.begin(), res.end());
- for (int i = 0; i < res.size(); i++) {
- cout << res[i] << ' ';
- }
- cout << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement