0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-19 21:45:25 +00:00

Compare commits

...

5 Commits

48 changed files with 466 additions and 0 deletions

87
BZOJ/1801/1801.cpp Normal file
View File

@ -0,0 +1,87 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
const int mod = 9999973;
int n, m;
long long f[N][N][N]{1}, ans;
long long C(long long x) {
return x * (x - 1) / 2;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
// 不增加炮
for (int j = 0; j <= m; j++) {
for (int k = 0; j + k <= m; k++) {
f[i][j][k] = f[i - 1][j][k];
}
}
// 增加 1 个炮
//
// 从 1 个炮增加到 2 个炮
for (int j = 0; j <= m; j++) {
for (int k = 1; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j + 1][k - 1] * (j + 1) % mod) % mod;
}
}
// 增加 1 个炮
//
// 从 0 个炮增加到 1 个炮
for (int j = 1; j <= m; j++) {
for (int k = 0; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j - 1][k] * (m - j - k + 1) % mod) % mod;
}
}
// 增加 2 个炮
//
// 一列从 0 个炮增加到 1 个炮
// 一列从 1 个炮增加到 2 个炮
for (int j = 0; j <= m; j++) {
for (int k = 1; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j][k - 1] * j * (m - j - k + 1) % mod) % mod;
}
}
// 增加 2 个炮
//
// 两列从 0 个炮增加到 1 个炮
for (int j = 2; j <= m; j++) {
for (int k = 0; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j - 2][k] * C(m - j - k + 2) % mod) % mod;
}
}
// 增加 2 个炮
//
// 两列从 1 个炮增加到 2 个炮
for (int j = 0; j <= m; j++) {
for (int k = 2; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j + 2][k - 2] * C(j + 2) % mod) % mod;
}
}
}
for (int i = 0; i <= m; i++) {
for (int j = 0; i + j <= m; j++) {
ans = (ans + f[n][i][j]) % mod;
}
}
cout << ans << endl;
return 0;
}

BIN
BZOJ/1801/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1801/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.

87
Luogu/P2051/P2051.cpp Normal file
View File

@ -0,0 +1,87 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
const int mod = 9999973;
int n, m;
long long f[N][N][N]{1}, ans;
long long C(long long x) {
return x * (x - 1) / 2;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
// 不增加炮
for (int j = 0; j <= m; j++) {
for (int k = 0; j + k <= m; k++) {
f[i][j][k] = f[i - 1][j][k];
}
}
// 增加 1 个炮
//
// 从 1 个炮增加到 2 个炮
for (int j = 0; j <= m; j++) {
for (int k = 1; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j + 1][k - 1] * (j + 1) % mod) % mod;
}
}
// 增加 1 个炮
//
// 从 0 个炮增加到 1 个炮
for (int j = 1; j <= m; j++) {
for (int k = 0; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j - 1][k] * (m - j - k + 1) % mod) % mod;
}
}
// 增加 2 个炮
//
// 一列从 0 个炮增加到 1 个炮
// 一列从 1 个炮增加到 2 个炮
for (int j = 0; j <= m; j++) {
for (int k = 1; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j][k - 1] * j * (m - j - k + 1) % mod) % mod;
}
}
// 增加 2 个炮
//
// 两列从 0 个炮增加到 1 个炮
for (int j = 2; j <= m; j++) {
for (int k = 0; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j - 2][k] * C(m - j - k + 2) % mod) % mod;
}
}
// 增加 2 个炮
//
// 两列从 1 个炮增加到 2 个炮
for (int j = 0; j <= m; j++) {
for (int k = 2; j + k <= m; k++) {
f[i][j][k] = (f[i][j][k] + f[i - 1][j + 2][k - 2] * C(j + 2) % mod) % mod;
}
}
}
for (int i = 0; i <= m; i++) {
for (int j = 0; i + j <= m; j++) {
ans = (ans + f[n][i][j]) % mod;
}
}
cout << ans << endl;
return 0;
}

54
Luogu/P2339/P2339.cpp Normal file
View File

@ -0,0 +1,54 @@
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <limits>
#include <utility>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1005;
int c, h, b, f[N][N][2], ans = std::numeric_limits<int>::max();
std::pair<int, int> a[N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
memset(f, 0x3f, sizeof(f));
cin >> c >> h >> b;
for (int i = 1; i <= c; i++) {
cin >> a[i].first >> a[i].second;
}
std::sort(a + 1, a + 1 + c);
f[0][c][0] = f[0][c][1] = 0;
for (int i = 1; i <= c; i++) {
for (int j = c; j >= i; j--) {
f[i][j][0] = std::min({
std::max(f[i - 1][j][0] + a[i].first - a[i - 1].first, a[i].second),
std::max(f[i][j + 1][1] + a[j + 1].first - a[i].first, a[i].second),
});
f[i][j][1] = std::min({
std::max(f[i - 1][j][0] + a[j].first - a[i - 1].first, a[j].second),
std::max(f[i][j + 1][1] + a[j + 1].first - a[j].first, a[j].second),
});
}
}
for (int i = 1; i <= c; i++) {
ans = std::min(ans, std::min(f[i][i][0], f[i][i][1]) + std::abs(b - a[i].first));
}
cout << ans << endl;
return 0;
}

55
Luogu/P4127/P4127.cpp Normal file
View File

@ -0,0 +1,55 @@
#include <iostream>
#include <bitset>
#include <cstring>
using std::cin;
using std::cout;
const char endl = '\n';
long long a, b, f[20][200][200], ans;
int c[20], p;
long long dfs(int len, int s, int x, bool limit) {
if (s + 9 * len < p) return 0;
if (!limit && f[len][s][x] != -1) return f[len][s][x];
if (!len) return s == p && x == 0;
int n = limit ? c[len] : 9;
long long res = 0;
for (int i = 0; i <= n && i + s <= p; i++)
res += dfs(len - 1, s + i, (x * 10 + i) % p, limit && (i == c[len]));
if (!limit) f[len][s][x] = res;
return res;
}
long long calc(long long x) {
int cnt = 0;
while (x) {
c[++cnt] = x % 10;
x /= 10;
}
long long res = 0;
for (p = 1; p <= cnt * 9; p++) {
memset(f, 0xff, sizeof(f));
res += dfs(cnt, 0, 0, 1);
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> a >> b;
cout << calc(b) - calc(a - 1) << endl;
return 0;
}

54
S2OJ/1539/1539.cpp Normal file
View File

@ -0,0 +1,54 @@
#include <iostream>
#include <algorithm>
using std::cin;
using std::cout;
const char endl = '\n';
int t, l, r, a, b, c, ans;
int p, cnt, primes[10000005], sum[10000005];
bool not_prime[10000005];
inline bool check(int x) {
int sum = 0;
while (x) {
sum += x % 10;
x /= 10;
}
return !not_prime[sum];
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
for (int i = 2; i <= 10000000; i++) {
if (!not_prime[i]) primes[++p] = i;
for (int j = 1; j <= p && primes[j] * i <= 10000000; j++) {
not_prime[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
for (int i = 1; i <= 10000000; i++) {
if (!not_prime[i] && check(i)) sum[i] = sum[i - 1] + 1;
else sum[i] = sum[i - 1];
}
cin >> t >> l >> r >> a >> b >> c;
while (t--) {
ans ^= sum[r] - sum[l - 1];
l = ((l ^ b) + a) % c + 1;
r = ((r ^ b) + a) % c + 1;
if (l > r) std::swap(l, r);
}
cout << ans << endl;
return 0;
}

BIN
S2OJ/1539/data/ex_number1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/ex_number1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/number9.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1539/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.