Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- int64_t n,k,a,b,c,d;
- int64_t ut;
- priority_queue <int64_t,vector <int64_t>,greater <int64_t>> V;
- int main()
- {
- cin>>n>>k>>a>>b>>c>>d;
- ut=a;
- V.push(ut);
- for(int i=2;i<=k;++i)
- ut=(b*ut+c)%d,V.push(ut);
- for(int i=k+1;i<=n;++i)
- {
- ut=(b*ut+c)%d;
- if(V.top()<ut)
- V.pop(),V.push(ut);
- }
- while(!V.empty())
- cout<<V.top()<< ' ',V.pop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement