From 230c52e2a50b62fedef339dae5c4db5173a56063 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 18 May 2022 21:39:51 +0800 Subject: [PATCH] =?UTF-8?q?#6283.=20=E6=95=B0=E5=88=97=E5=88=86=E5=9D=97?= =?UTF-8?q?=E5=85=A5=E9=97=A8=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1466084 --- LibreOJ/6283/6283.cpp | 108 ++++++++++++++++++++++++++++++++++++++ LibreOJ/6283/data/a1.in | 3 ++ LibreOJ/6283/data/a1.out | 3 ++ LibreOJ/6283/data/a10.in | 3 ++ LibreOJ/6283/data/a10.out | 3 ++ LibreOJ/6283/data/a2.in | 3 ++ LibreOJ/6283/data/a2.out | 3 ++ LibreOJ/6283/data/a3.in | 3 ++ LibreOJ/6283/data/a3.out | 3 ++ LibreOJ/6283/data/a4.in | 3 ++ LibreOJ/6283/data/a4.out | 3 ++ LibreOJ/6283/data/a5.in | 3 ++ LibreOJ/6283/data/a5.out | 3 ++ LibreOJ/6283/data/a6.in | 3 ++ LibreOJ/6283/data/a6.out | 3 ++ LibreOJ/6283/data/a7.in | 3 ++ LibreOJ/6283/data/a7.out | 3 ++ LibreOJ/6283/data/a8.in | 3 ++ LibreOJ/6283/data/a8.out | 3 ++ LibreOJ/6283/data/a9.in | 3 ++ LibreOJ/6283/data/a9.out | 3 ++ 21 files changed, 168 insertions(+) create mode 100644 LibreOJ/6283/6283.cpp create mode 100644 LibreOJ/6283/data/a1.in create mode 100644 LibreOJ/6283/data/a1.out create mode 100644 LibreOJ/6283/data/a10.in create mode 100644 LibreOJ/6283/data/a10.out create mode 100644 LibreOJ/6283/data/a2.in create mode 100644 LibreOJ/6283/data/a2.out create mode 100644 LibreOJ/6283/data/a3.in create mode 100644 LibreOJ/6283/data/a3.out create mode 100644 LibreOJ/6283/data/a4.in create mode 100644 LibreOJ/6283/data/a4.out create mode 100644 LibreOJ/6283/data/a5.in create mode 100644 LibreOJ/6283/data/a5.out create mode 100644 LibreOJ/6283/data/a6.in create mode 100644 LibreOJ/6283/data/a6.out create mode 100644 LibreOJ/6283/data/a7.in create mode 100644 LibreOJ/6283/data/a7.out create mode 100644 LibreOJ/6283/data/a8.in create mode 100644 LibreOJ/6283/data/a8.out create mode 100644 LibreOJ/6283/data/a9.in create mode 100644 LibreOJ/6283/data/a9.out diff --git a/LibreOJ/6283/6283.cpp b/LibreOJ/6283/6283.cpp new file mode 100644 index 00000000..8bfdfb91 --- /dev/null +++ b/LibreOJ/6283/6283.cpp @@ -0,0 +1,108 @@ +#include +#include +#include + +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; +} diff --git a/LibreOJ/6283/data/a1.in b/LibreOJ/6283/data/a1.in new file mode 100644 index 00000000..36cf6771 --- /dev/null +++ b/LibreOJ/6283/data/a1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e1915d6173ebc56ce0726521b9ea36b86da5c2149da4f30029d63c312792d42 +size 106580 diff --git a/LibreOJ/6283/data/a1.out b/LibreOJ/6283/data/a1.out new file mode 100644 index 00000000..731fb36f --- /dev/null +++ b/LibreOJ/6283/data/a1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31ed0254072fd4cb8fd4bb2100311ca69c30ea6ae946e88c297b010f926891b5 +size 8189 diff --git a/LibreOJ/6283/data/a10.in b/LibreOJ/6283/data/a10.in new file mode 100644 index 00000000..1e18b930 --- /dev/null +++ b/LibreOJ/6283/data/a10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:353192ce4fd49faef039b9e177396b3e69821da800075e53bd9c8b64638a0994 +size 2355588 diff --git a/LibreOJ/6283/data/a10.out b/LibreOJ/6283/data/a10.out new file mode 100644 index 00000000..1193a265 --- /dev/null +++ b/LibreOJ/6283/data/a10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2764b70f6175b08e47f0b9b84d218a0033842ee2f5305cb67fc2135aecce90b8 +size 162697 diff --git a/LibreOJ/6283/data/a2.in b/LibreOJ/6283/data/a2.in new file mode 100644 index 00000000..36cf6771 --- /dev/null +++ b/LibreOJ/6283/data/a2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e1915d6173ebc56ce0726521b9ea36b86da5c2149da4f30029d63c312792d42 +size 106580 diff --git a/LibreOJ/6283/data/a2.out b/LibreOJ/6283/data/a2.out new file mode 100644 index 00000000..731fb36f --- /dev/null +++ b/LibreOJ/6283/data/a2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31ed0254072fd4cb8fd4bb2100311ca69c30ea6ae946e88c297b010f926891b5 +size 8189 diff --git a/LibreOJ/6283/data/a3.in b/LibreOJ/6283/data/a3.in new file mode 100644 index 00000000..36cf6771 --- /dev/null +++ b/LibreOJ/6283/data/a3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e1915d6173ebc56ce0726521b9ea36b86da5c2149da4f30029d63c312792d42 +size 106580 diff --git a/LibreOJ/6283/data/a3.out b/LibreOJ/6283/data/a3.out new file mode 100644 index 00000000..731fb36f --- /dev/null +++ b/LibreOJ/6283/data/a3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31ed0254072fd4cb8fd4bb2100311ca69c30ea6ae946e88c297b010f926891b5 +size 8189 diff --git a/LibreOJ/6283/data/a4.in b/LibreOJ/6283/data/a4.in new file mode 100644 index 00000000..bd2109b4 --- /dev/null +++ b/LibreOJ/6283/data/a4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f576b021c19f61814a2934e2ca3c8da47e0a5c44b8d5c01b51cd4621207399f +size 2355709 diff --git a/LibreOJ/6283/data/a4.out b/LibreOJ/6283/data/a4.out new file mode 100644 index 00000000..9e2da880 --- /dev/null +++ b/LibreOJ/6283/data/a4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b50a44fc1ec5acdd56625a5bab672d41730e94851025f72082e889c6e1f8f46 +size 164303 diff --git a/LibreOJ/6283/data/a5.in b/LibreOJ/6283/data/a5.in new file mode 100644 index 00000000..c98ccc99 --- /dev/null +++ b/LibreOJ/6283/data/a5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc526b66935f216da980f0a8d1863d355fe325283acdcfffc96389152eb77843 +size 2355563 diff --git a/LibreOJ/6283/data/a5.out b/LibreOJ/6283/data/a5.out new file mode 100644 index 00000000..b5631de3 --- /dev/null +++ b/LibreOJ/6283/data/a5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4bc88366a3d7824f88e95fb3a36677876aab1c54779ea7001f4ff4002b63b647 +size 163068 diff --git a/LibreOJ/6283/data/a6.in b/LibreOJ/6283/data/a6.in new file mode 100644 index 00000000..7b224ebe --- /dev/null +++ b/LibreOJ/6283/data/a6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31a61d2b6cacd67ecdb95098c9122ad1382e97a2e6a2b705d452ef9e9fe4725a +size 2355448 diff --git a/LibreOJ/6283/data/a6.out b/LibreOJ/6283/data/a6.out new file mode 100644 index 00000000..ad67f015 --- /dev/null +++ b/LibreOJ/6283/data/a6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:681e73536a9b93502135ed35c27b2eaf141a952f207e7dd4c00fe4ec8d084a10 +size 163183 diff --git a/LibreOJ/6283/data/a7.in b/LibreOJ/6283/data/a7.in new file mode 100644 index 00000000..4e2eabe4 --- /dev/null +++ b/LibreOJ/6283/data/a7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:deadf8a13be71f4efd7056df7939f368af8f3c89a682e7c5a2bc562dbe50eb37 +size 2355985 diff --git a/LibreOJ/6283/data/a7.out b/LibreOJ/6283/data/a7.out new file mode 100644 index 00000000..f5bbc66b --- /dev/null +++ b/LibreOJ/6283/data/a7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b139ac0ee5618e7bc46f7297ad00c4afa965d05dcda4a34cdc8fe7e6172cf2a +size 162056 diff --git a/LibreOJ/6283/data/a8.in b/LibreOJ/6283/data/a8.in new file mode 100644 index 00000000..e200bdc7 --- /dev/null +++ b/LibreOJ/6283/data/a8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d5f48ef64426eb0c887955242e9b23ef862563b0330fd68e4632ae813d53ce3 +size 2355452 diff --git a/LibreOJ/6283/data/a8.out b/LibreOJ/6283/data/a8.out new file mode 100644 index 00000000..c203e74e --- /dev/null +++ b/LibreOJ/6283/data/a8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26de302e141fb33e1ebf4ef0283a458acc4439ac3b126fb7283f2fb08b67a317 +size 163317 diff --git a/LibreOJ/6283/data/a9.in b/LibreOJ/6283/data/a9.in new file mode 100644 index 00000000..7c7761ed --- /dev/null +++ b/LibreOJ/6283/data/a9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb4ed1e48f081cd7462f83fcee33b9a5d9fc483e7596a8d719accebae0344346 +size 2355827 diff --git a/LibreOJ/6283/data/a9.out b/LibreOJ/6283/data/a9.out new file mode 100644 index 00000000..adf9455e --- /dev/null +++ b/LibreOJ/6283/data/a9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17bd80117d04bc661e9102e39720fe557b855d8ee2997612383df8d79eeb6ee6 +size 163293