mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 18:08:47 +00:00
Compare commits
2 Commits
7f9094e5ec
...
f36ed8c800
Author | SHA1 | Date | |
---|---|---|---|
f36ed8c800 | |||
f1fed88c8a |
75
S2OJ/1486/1486.cpp
Normal file
75
S2OJ/1486/1486.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
BIN
S2OJ/1486/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1486/data/set9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1486/data/set9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
51
S2OJ/45/45.cpp
Normal file
51
S2OJ/45/45.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 105,
|
||||
M = 17;
|
||||
|
||||
int n, m, fee[N], cost[N][M], f[N][1 << M], ans = 0x3f3f3f3f;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> fee[i];
|
||||
|
||||
for (int j = 0; j < m; j++) {
|
||||
cin >> cost[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
memset(f[0], 0x3f, sizeof(f[0]));
|
||||
f[0][0] = 0;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 0; j < 1 << m; j++) {
|
||||
f[i][j] = f[i - 1][j] + fee[i];
|
||||
}
|
||||
|
||||
for (int j = 0; j < 1 << m; j++) {
|
||||
for (int k = 0; k < m; k++) {
|
||||
if (j & (1 << k)) continue;
|
||||
|
||||
f[i][j | (1 << k)] = std::min(f[i][j | (1 << k)], f[i][j] + cost[i][k]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 1 << m; j++) {
|
||||
f[i][j] = std::min(f[i][j], f[i - 1][j]);
|
||||
}
|
||||
}
|
||||
|
||||
cout << f[n][(1 << m) - 1] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/45/data/cen1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen11.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen12.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen13.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen14.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen14.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen15.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen15.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen16.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen16.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/ex_cen1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/ex_cen1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/ex_cen1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/ex_cen1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/ex_cen2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/ex_cen2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/ex_cen2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/ex_cen2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user