mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 13:16:26 +00:00
parent
19112fd610
commit
56c8b7aff7
108
S2OJ/1445/1445.cpp
Normal file
108
S2OJ/1445/1445.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e5 + 5;
|
||||
const int mod = 10007;
|
||||
|
||||
int n, t, c, a[N], st[N], ed[N], add[N], mul[N], pos[N];
|
||||
|
||||
inline void update(int x) {
|
||||
for (int i = st[x]; i <= ed[x]; i++) {
|
||||
a[i] = (a[i] * mul[x] % mod + add[x]) % mod;
|
||||
}
|
||||
|
||||
mul[x] = 1;
|
||||
add[x] = 0;
|
||||
}
|
||||
|
||||
// 加法
|
||||
void change1(int l, int r, int c) {
|
||||
int p = pos[l],
|
||||
q = pos[r];
|
||||
|
||||
if (p == q) {
|
||||
update(p);
|
||||
|
||||
for (int i = l; i <= r; i++) {
|
||||
a[i] = (a[i] + c) % mod;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
update(p);
|
||||
for (int i = l; i <= ed[p]; i++) a[i] = (a[i] + c) % mod;
|
||||
update(q);
|
||||
for (int i = st[q]; i <= r; i++) a[i] = (a[i] + c) % mod;
|
||||
for (int i = p + 1; i <= q - 1; i++) add[i] = (add[i] + c) % mod;
|
||||
}
|
||||
|
||||
// 乘法
|
||||
void change2(int l, int r, int c) {
|
||||
int p = pos[l],
|
||||
q = pos[r];
|
||||
|
||||
if (p == q) {
|
||||
update(p);
|
||||
|
||||
for (int i = l; i <= r; i++) {
|
||||
a[i] = a[i] * c % mod;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
update(p);
|
||||
for (int i = l; i <= ed[p]; i++) a[i] = a[i] * c % mod;
|
||||
update(q);
|
||||
for (int i = st[q]; i <= r; i++) a[i] = a[i] * c % mod;
|
||||
for (int i = p + 1; i <= q - 1; i++) {
|
||||
mul[i] = mul[i] * c % mod;
|
||||
add[i] = add[i] * c % mod;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
|
||||
std::fill(mul, mul + n + 2, 1);
|
||||
t = std::sqrt(n);
|
||||
|
||||
for (c = 1;; c++) {
|
||||
st[c] = (c - 1) * t + 1;
|
||||
ed[c] = std::min(n, c * t);
|
||||
|
||||
if (c * t >= n) break;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= c; i++) {
|
||||
for (int j = st[i]; j <= ed[i]; j++) {
|
||||
pos[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1, op, l, r, c; i <= n; i++) {
|
||||
cin >> op >> l >> r >> c;
|
||||
|
||||
if (op == 0) {
|
||||
change1(l, r, c);
|
||||
} else if (op == 1) {
|
||||
change2(l, r, c);
|
||||
} else { // op == 2
|
||||
cout << (a[r] * mul[pos[r]] % mod + add[pos[r]]) % mod << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1445/data/a1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1445/data/a9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1445/data/a9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user