Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <cmath>
  4. #include <stack>
  5. #include <cstring>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main() {
  11. long long n, x, y, a0;
  12. cin >> n >> x >> y >> a0;
  13. long long a[n];
  14. a[0] = a0;
  15. for (int i = 1; i < n; i++) {
  16. a[i] = x * a[i - 1] + y;
  17. }
  18. for (int i = 1; i < n; i++) {
  19. a[i] = a[i] + a[i - 1];
  20. }
  21.  
  22. int m, z, t, b0;
  23. cin >> m >> z >> t >> b0;
  24. int b[2 * m];
  25. int c[2 * m];
  26. b[0] = b0;
  27. for (int i = 1; i < 2 * m; i++) {
  28. b[i] = (z * b[i - 1] + t) & ((1 << 30) - 1);
  29. }
  30. for (int i = 0; i < 2 * m; i++) {
  31. c[i] = b[i] % n;
  32. }
  33.  
  34. for (int i = 0; i < 2*m - 1; i+=2){
  35. cout << a[max(c[i], c[i+1])] - a[min(c[i], c[i+1])-1] << " ";
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement