mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 14:18:47 +00:00
#1972. 【Public NOIP Round #5】青鱼和区间
https://sjzezoj.com/submission/72660
This commit is contained in:
parent
d7bd7cf57e
commit
925330530c
46
S2OJ/1972/1972.cpp
Normal file
46
S2OJ/1972/1972.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 305;
|
||||
|
||||
int n, p, f[N][N], d[N], p2[N * N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> p;
|
||||
|
||||
p2[0] = 1;
|
||||
|
||||
for (int i = 1; i <= n * n; i++) {
|
||||
p2[i] = static_cast<long long>(p2[i - 1]) * 2 % p;
|
||||
}
|
||||
|
||||
f[1][1] = 1;
|
||||
|
||||
for (int i = 2; i <= n; i++) {
|
||||
f[i][1] = p2[(i - 1) * (i - 2) / 2];
|
||||
|
||||
for (int j = 2; j <= i; j++) {
|
||||
for (int k = 1; k < i; k++) {
|
||||
f[i][j] = (f[i][j] + static_cast<long long>(f[k][j - 1]) * p2[(i - k - 1) * (i - k - 2) / 2] % p) % p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
d[i] = p2[i * (i + 1) / 2];
|
||||
|
||||
for (int j = 1; j < i; j++) {
|
||||
d[i] = ((d[i] - static_cast<long long>(f[i][j]) * d[j]) % p + p) % p;
|
||||
}
|
||||
}
|
||||
|
||||
cout << d[n] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1972/data/interval1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval10.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval3.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval4.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval5.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval6.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval7.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval8.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval9.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/interval9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/interval9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1972/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1972/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user