diff --git a/S2OJ/1486/1486.cpp b/S2OJ/1486/1486.cpp new file mode 100644 index 00000000..63cda4ba --- /dev/null +++ b/S2OJ/1486/1486.cpp @@ -0,0 +1,75 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2e5 + 5, + K = 55; +const int mod = 1e9 + 7; + +int m, k, d, cnt; +long long f[K][K], p[N][K], s[N][K], sum; + +long long binpow(long long a, long long b) { + a %= mod; + + long long res = 1; + + while (b) { + if (b & 1) res = res * a % mod; + a = a * a % mod; + b >>= 1; + } + + return res; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> m >> k; + + f[0][0] = 1; + for (int i = 1; i <= k; i++) { + f[i][0] = 1; + + for (int j = 1; j <= i; j++) { + f[i][j] = (f[i - 1][j - 1] + f[i - 1][j]) % mod; + } + } + + while (m--) { + int op; + + cin >> op; + + if (op == 0) { + int x; + + cin >> x; + + p[++cnt][0] = 1; + s[cnt][0] = (s[cnt - 1][0] + p[cnt][0]) % mod; + + for (int i = 1; i <= k; i++) { + p[cnt][i] = (p[cnt][i - 1] * (x - d) % mod + mod) % mod; + s[cnt][i] = (s[cnt - 1][i] + p[cnt][i]) % mod; + } + + sum = (sum + binpow(x, k)) % mod; + } else { // op == 1 + d++; + + sum = 0; + for (int i = 0; i <= k; i++) { + sum = (sum + f[k][i] * binpow(d, i) % mod * s[cnt][k - i] % mod) % mod; + } + } + + cout << sum << endl; + } + + return 0; +} diff --git a/S2OJ/1486/data/problem.conf b/S2OJ/1486/data/problem.conf new file mode 100644 index 00000000..44f9b1aa --- /dev/null +++ b/S2OJ/1486/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:845952a9aec741e791239d6248f1f6ee4ec8a208b8733f6a28999253bcf2dceb +size 175 diff --git a/S2OJ/1486/data/set1.in b/S2OJ/1486/data/set1.in new file mode 100644 index 00000000..ede1d1ae --- /dev/null +++ b/S2OJ/1486/data/set1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e8ce4eba67f48ddb691f94ae8b9f1956b4b2d44b1b0359ff6f4022e2347992e +size 978202 diff --git a/S2OJ/1486/data/set1.out b/S2OJ/1486/data/set1.out new file mode 100644 index 00000000..407efeb6 --- /dev/null +++ b/S2OJ/1486/data/set1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:496f85985939c3a8ca95f5688ceee754f6e18c275eb91b46bb89f419fae5fa32 +size 1962018 diff --git a/S2OJ/1486/data/set10.in b/S2OJ/1486/data/set10.in new file mode 100644 index 00000000..403734eb --- /dev/null +++ b/S2OJ/1486/data/set10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a019236ee02d5b5ff5e8a32bd9720875832cbd4548d1c4c3291cffc2b385a71 +size 927328 diff --git a/S2OJ/1486/data/set10.out b/S2OJ/1486/data/set10.out new file mode 100644 index 00000000..527c0bc8 --- /dev/null +++ b/S2OJ/1486/data/set10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2574d0a31681dcfab16502af2fc9d620eb1f8d4c42cde7909c014c6061e01af +size 1855215 diff --git a/S2OJ/1486/data/set2.in b/S2OJ/1486/data/set2.in new file mode 100644 index 00000000..1b9d1c3c --- /dev/null +++ b/S2OJ/1486/data/set2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d68377e5431ded829b310d584b6031bbd809068f1406389a0f14a7972f4140b3 +size 14597 diff --git a/S2OJ/1486/data/set2.out b/S2OJ/1486/data/set2.out new file mode 100644 index 00000000..cfee0cb7 --- /dev/null +++ b/S2OJ/1486/data/set2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c9f6d6254af38dd25f78ec0ac792165694e41afc1cb7ed7a9759765d9fb0539f +size 29657 diff --git a/S2OJ/1486/data/set3.in b/S2OJ/1486/data/set3.in new file mode 100644 index 00000000..6835e7ef --- /dev/null +++ b/S2OJ/1486/data/set3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5617db12423a36e4e452a66567a7b46449ee83d2a9c4e72df6a06d9b0f6ab393 +size 14782 diff --git a/S2OJ/1486/data/set3.out b/S2OJ/1486/data/set3.out new file mode 100644 index 00000000..03cbfafb --- /dev/null +++ b/S2OJ/1486/data/set3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5537c3c82d388188023d91c82c9703ac84ddcb43d09a2e1fdc7645e241500692 +size 29691 diff --git a/S2OJ/1486/data/set4.in b/S2OJ/1486/data/set4.in new file mode 100644 index 00000000..bce6309f --- /dev/null +++ b/S2OJ/1486/data/set4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d65c20d9beb2611039ceaaa3aab22f97eb8300bff4d87f4b25217d8bda501043 +size 903640 diff --git a/S2OJ/1486/data/set4.out b/S2OJ/1486/data/set4.out new file mode 100644 index 00000000..87b1109e --- /dev/null +++ b/S2OJ/1486/data/set4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18a2b08abce95b494e9ca91e71a4ed9a7a4ac4df16bcc664f86c01ebb21cdd4c +size 1810602 diff --git a/S2OJ/1486/data/set5.in b/S2OJ/1486/data/set5.in new file mode 100644 index 00000000..d16cc01c --- /dev/null +++ b/S2OJ/1486/data/set5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bae9a29b3b407691617757fa03bed21763591f60813fc1bf90d3087ef9ced6ff +size 932374 diff --git a/S2OJ/1486/data/set5.out b/S2OJ/1486/data/set5.out new file mode 100644 index 00000000..0faf7d08 --- /dev/null +++ b/S2OJ/1486/data/set5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5e754e7fc171813ebbe5066407b71939388725520076d37f6ce4827ffa4fb1c +size 1864033 diff --git a/S2OJ/1486/data/set6.in b/S2OJ/1486/data/set6.in new file mode 100644 index 00000000..9472e4ca --- /dev/null +++ b/S2OJ/1486/data/set6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:503984839aa192967e5aa53c83957a69c0347c69d27420b99555b6c242e6b832 +size 955928 diff --git a/S2OJ/1486/data/set6.out b/S2OJ/1486/data/set6.out new file mode 100644 index 00000000..203bdeea --- /dev/null +++ b/S2OJ/1486/data/set6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:892ddd05dc9db88bff192ee239970d2b673f3d7124b0bfe2cc8b846d8e57fb92 +size 1914062 diff --git a/S2OJ/1486/data/set7.in b/S2OJ/1486/data/set7.in new file mode 100644 index 00000000..81a35d6b --- /dev/null +++ b/S2OJ/1486/data/set7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0d6922262b62adf15631ac23628b33a21d24802471d5c32cc068be255448013 +size 942961 diff --git a/S2OJ/1486/data/set7.out b/S2OJ/1486/data/set7.out new file mode 100644 index 00000000..ffd2bdb8 --- /dev/null +++ b/S2OJ/1486/data/set7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bcc350cef524857839929156d571afdf5d8655aed162e34ecc4e844b0cd2cf98 +size 1885660 diff --git a/S2OJ/1486/data/set8.in b/S2OJ/1486/data/set8.in new file mode 100644 index 00000000..bb0490d9 --- /dev/null +++ b/S2OJ/1486/data/set8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e34ee62b2c92d66bc0e2a523258b2ead3d25dc2b5550b13a9c2e9fff76cd20a +size 978832 diff --git a/S2OJ/1486/data/set8.out b/S2OJ/1486/data/set8.out new file mode 100644 index 00000000..27b51721 --- /dev/null +++ b/S2OJ/1486/data/set8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eca38aee1df8aa3b205cd9c6e62694cb7263605d34e1115d79eb762ba95a6fa4 +size 1957603 diff --git a/S2OJ/1486/data/set9.in b/S2OJ/1486/data/set9.in new file mode 100644 index 00000000..51a1a876 --- /dev/null +++ b/S2OJ/1486/data/set9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b9ed96eb4b300eff448efec01d9996a4f2df91fcb0fe25bcad270df2e240ea2 +size 989218 diff --git a/S2OJ/1486/data/set9.out b/S2OJ/1486/data/set9.out new file mode 100644 index 00000000..f993c083 --- /dev/null +++ b/S2OJ/1486/data/set9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:769404718e7f501b8c1109f747478654b57137691a03354568ad0c6053f130a1 +size 1976562