Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- priority_queue<int,vector<long long>,greater<int>> v;
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- long long n, k ,a ,b ,c ,d , x;
- cin >> n >> k >> a >> b >> c >> d;
- v.push(a);
- for(int i = 2;i <= n; i++)
- {
- x = (b*a+c) % d;
- if(x>v.top())
- v.push(x);
- while(v.size() > k)
- v.pop();
- a = x;
- }
- while(v.size())
- {
- cout << v.top() << " ";
- v.pop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement