0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 21:08:47 +00:00

#779. 0825区间 (range)

https://sjzezoj.com/submission/22511
This commit is contained in:
Baoshuo Ren 2021-08-25 16:17:22 +08:00 committed by Baoshuo Ren
parent cf2b686362
commit 04ca89fcc7
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

37
S2OJ/779/779.cpp Normal file
View File

@ -0,0 +1,37 @@
#include <bits/stdc++.h>
using namespace std;
int n, k, p, a, b, c, d, s[20000005], pre[20000005], suc[20000005], ans;
int main() {
cin >> n >> k >> p;
cin >> a >> b >> c >> d;
s[1] = a;
for (int i = 2; i <= n; i++) {
s[i] = (1ll * s[i - 1] * b + c) % d;
}
for (int i = 1; i <= n; i++) {
if ((i - 1) % k) {
pre[i] = 1ll * pre[i - 1] * s[i] % p;
} else {
pre[i] = s[i];
}
}
for (int i = n; i > 0; i--) {
if (i % k) {
suc[i] = 1ll * suc[i + 1] * s[i] % p;
} else {
suc[i] = s[i];
}
}
for (int i = 1; i <= n - k + 1; i++) {
if ((i - 1) % k) {
ans ^= 1ll * suc[i] * pre[i + k - 1] % p;
} else {
ans ^= pre[i + k - 1];
}
}
cout << ans << endl;
return 0;
}