Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAXN 16777216
- #include <iostream>
- #include <fstream>
- #include <cmath>
- #include <string>
- #include <cstdio>
- using namespace std;
- unsigned int add, l, r;
- unsigned int nextRand();
- unsigned int cur = 0;
- unsigned int m, q, c, b;
- long long a[MAXN + 1];
- unsigned int lal = 0;
- int main(){
- ifstream cin("input.txt");
- ofstream cout("output.txt");
- cin >> m >> q >> c >> b;
- memset(a, 0, sizeof(a));
- for (int i = 0; i < m; i++){
- add = nextRand();
- l = nextRand();
- r = nextRand();
- if (l > r) swap(l, r);
- a[l] += add;
- a[r + 1] -= add;
- }
- for (int i = 1; i < MAXN; i++)
- a[i] += a[i - 1];
- for (int i = 0; i < q; i++){
- l = nextRand();
- r = nextRand();
- if (l > r) swap(l, r);
- if (l == 0)
- lal += a[r];
- else lal += a[r] - a[l - 1];
- }
- cout << lal;
- return 0;
- }
- unsigned int nextRand() {
- cur = cur * c + b;
- return cur >> 8;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement