Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. priority_queue<int,vector<long long>,greater<int>> v;
  5.  
  6. int main()
  7. {
  8. ios::sync_with_stdio(false);
  9.  
  10. cin.tie(0);
  11. cout.tie(0);
  12.  
  13. long long n, k ,a ,b ,c ,d , x;
  14.  
  15. cin >> n >> k >> a >> b >> c >> d;
  16.  
  17. v.push(a);
  18.  
  19. for(int i = 2;i <= n; i++)
  20. {
  21. x = (b*a+c) % d;
  22. if(x>v.top())
  23. v.push(x);
  24. while(v.size() > k)
  25. v.pop();
  26. a = x;
  27. }
  28. while(v.size())
  29. {
  30. cout << v.top() << " ";
  31. v.pop();
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement