Advertisement
a53

lastk

a53
Apr 8th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. using namespace std;
  4. int64_t n,k,a,b,c,d;
  5. int64_t ut;
  6. priority_queue <int64_t,vector <int64_t>,greater <int64_t>> V;
  7.  
  8. int main()
  9. {
  10. cin>>n>>k>>a>>b>>c>>d;
  11. ut=a;
  12. V.push(ut);
  13. for(int i=2;i<=k;++i)
  14. ut=(b*ut+c)%d,V.push(ut);
  15. for(int i=k+1;i<=n;++i)
  16. {
  17. ut=(b*ut+c)%d;
  18. if(V.top()<ut)
  19. V.pop(),V.push(ut);
  20. }
  21. while(!V.empty())
  22. cout<<V.top()<< ' ',V.pop();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement