Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <cmath>
- #include <stack>
- #include <cstring>
- using namespace std;
- int main() {
- long long n, x, y, a0;
- cin >> n >> x >> y >> a0;
- long long a[n];
- a[0] = a0;
- for (int i = 1; i < n; i++) {
- a[i] = x * a[i - 1] + y;
- }
- for (int i = 1; i < n; i++) {
- a[i] = a[i] + a[i - 1];
- }
- int m, z, t, b0;
- cin >> m >> z >> t >> b0;
- int b[2 * m];
- int c[2 * m];
- b[0] = b0;
- for (int i = 1; i < 2 * m; i++) {
- b[i] = (z * b[i - 1] + t) & ((1 << 30) - 1);
- }
- for (int i = 0; i < 2 * m; i++) {
- c[i] = b[i] % n;
- }
- for (int i = 0; i < 2*m - 1; i+=2){
- cout << a[max(c[i], c[i+1])] - a[min(c[i], c[i+1])-1] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement