QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#447408 | #2430. Gem Island | zhaohaikun | AC ✓ | 275ms | 15964kb | C++20 | 1.7kb | 2024-06-18 13:34:09 | 2024-06-18 13:34:09 |
Judging History
answer
#include <bits/stdc++.h>
#define SZ(x) (int)x.size() - 1
#define all(x) x.begin(), x.end()
#define F(i, a, b) for (int i = (a); i <= (b); i++)
#define DF(i, a, b) for (int i = (a); i >= (b); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> inline void chkmin(T &x, T y) {x = min(x, y); }
template <typename T> inline void read(T &x) {
x = 0; int f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
x *= f;
}
template <typename T> inline void write(T x) {
T l = 0;
ull y = 0;
if (!x) { putchar(48); return; }
if (x < 0) { x = -x; putchar('-'); }
while (x) { y = y * 10 + x % 10; x /= 10; ++l; }
while (l) { putchar(y % 10 + 48); y /= 10; --l; }
}
template <typename T> inline void writeln(T x) { write(x); puts(""); }
template <typename T> inline void writes(T x) { write(x); putchar(32); }
const int N = 510;
long double C[N][N], f[N][N], g[N][N];
signed main() {
int n, d, r; read(n); read(d); read(r);
C[0][0] = 1;
F(i, 1, n) {
C[i][0] = 1;
F(j, 1, i)
C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
}
// F(i, 1, d){
// F(j, 0, i) cout << C[i][j] << " "; cout << endl;
// }
// cout << C[3][2] << endl;
// f[0][0] = 1;
F(i, 1, n) {
f[i][0] = 1;
F(j, 1, d)
F(k, 0, min(i, j)) {
f[i][j] += C[i][k] * f[k][j - k];
g[i][j] += C[i][k] * (g[k][j - k] + min(k, r) * f[k][j - k]);
}
}
// cout << f[n][d] << " " << g[n][d] << endl;
cout << fixed << setprecision(25) << (long double) g[n][d] / f[n][d] + r;
return 0;
}
Details
Test #1:
score: 100
Accepted
time: 1ms
memory: 7996kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 7948kb
Test #3:
score: 0
Accepted
time: 1ms
memory: 7956kb
Test #4:
score: 0
Accepted
time: 1ms
memory: 7988kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 7944kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 7940kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 7936kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 7952kb
Test #9:
score: 0
Accepted
time: 1ms
memory: 7928kb
Test #10:
score: 0
Accepted
time: 1ms
memory: 8044kb
Test #11:
score: 0
Accepted
time: 0ms
memory: 7960kb
Test #12:
score: 0
Accepted
time: 1ms
memory: 7804kb
Test #13:
score: 0
Accepted
time: 1ms
memory: 7940kb
Test #14:
score: 0
Accepted
time: 1ms
memory: 7940kb
Test #15:
score: 0
Accepted
time: 1ms
memory: 7996kb
Test #16:
score: 0
Accepted
time: 1ms
memory: 7984kb
Test #17:
score: 0
Accepted
time: 1ms
memory: 7992kb
Test #18:
score: 0
Accepted
time: 0ms
memory: 7860kb
Test #19:
score: 0
Accepted
time: 1ms
memory: 8008kb
Test #20:
score: 0
Accepted
time: 0ms
memory: 8000kb
Test #21:
score: 0
Accepted
time: 1ms
memory: 8000kb
Test #22:
score: 0
Accepted
time: 1ms
memory: 8000kb
Test #23:
score: 0
Accepted
time: 1ms
memory: 7972kb
Test #24:
score: 0
Accepted
time: 1ms
memory: 7800kb
Test #25:
score: 0
Accepted
time: 1ms
memory: 7952kb
Test #26:
score: 0
Accepted
time: 1ms
memory: 7860kb
Test #27:
score: 0
Accepted
time: 0ms
memory: 7992kb
Test #28:
score: 0
Accepted
time: 0ms
memory: 7800kb
Test #29:
score: 0
Accepted
time: 0ms
memory: 8004kb
Test #30:
score: 0
Accepted
time: 1ms
memory: 8000kb
Test #31:
score: 0
Accepted
time: 1ms
memory: 7948kb
Test #32:
score: 0
Accepted
time: 1ms
memory: 7980kb
Test #33:
score: 0
Accepted
time: 1ms
memory: 7868kb
Test #34:
score: 0
Accepted
time: 1ms
memory: 7956kb
Test #35:
score: 0
Accepted
time: 1ms
memory: 7952kb
Test #36:
score: 0
Accepted
time: 1ms
memory: 7928kb
Test #37:
score: 0
Accepted
time: 1ms
memory: 7868kb
Test #38:
score: 0
Accepted
time: 0ms
memory: 7960kb
Test #39:
score: 0
Accepted
time: 1ms
memory: 8004kb
Test #40:
score: 0
Accepted
time: 1ms
memory: 8004kb
Test #41:
score: 0
Accepted
time: 1ms
memory: 7960kb
Test #42:
score: 0
Accepted
time: 1ms
memory: 7948kb
Test #43:
score: 0
Accepted
time: 1ms
memory: 7840kb
Test #44:
score: 0
Accepted
time: 1ms
memory: 12120kb
Test #45:
score: 0
Accepted
time: 1ms
memory: 8016kb
Test #46:
score: 0
Accepted
time: 1ms
memory: 7980kb
Test #47:
score: 0
Accepted
time: 1ms
memory: 7892kb
Test #48:
score: 0
Accepted
time: 1ms
memory: 8024kb
Test #49:
score: 0
Accepted
time: 0ms
memory: 8068kb
Test #50:
score: 0
Accepted
time: 0ms
memory: 8012kb
Test #51:
score: 0
Accepted
time: 1ms
memory: 8088kb
Test #52:
score: 0
Accepted
time: 2ms
memory: 8304kb
Test #53:
score: 0
Accepted
time: 1ms
memory: 8260kb
Test #54:
score: 0
Accepted
time: 5ms
memory: 8368kb
Test #55:
score: 0
Accepted
time: 5ms
memory: 8316kb
Test #56:
score: 0
Accepted
time: 2ms
memory: 12556kb
Test #57:
score: 0
Accepted
time: 1ms
memory: 8392kb
Test #58:
score: 0
Accepted
time: 0ms
memory: 12424kb
Test #59:
score: 0
Accepted
time: 3ms
memory: 8444kb
Test #60:
score: 0
Accepted
time: 3ms
memory: 8572kb
Test #61:
score: 0
Accepted
time: 10ms
memory: 8784kb
Test #62:
score: 0
Accepted
time: 0ms
memory: 12776kb
Test #63:
score: 0
Accepted
time: 2ms
memory: 13104kb
Test #64:
score: 0
Accepted
time: 0ms
memory: 13284kb
Test #65:
score: 0
Accepted
time: 89ms
memory: 13952kb
Test #66:
score: 0
Accepted
time: 56ms
memory: 13800kb
Test #67:
score: 0
Accepted
time: 5ms
memory: 13908kb
Test #68:
score: 0
Accepted
time: 0ms
memory: 12648kb
Test #69:
score: 0
Accepted
time: 0ms
memory: 14240kb
Test #70:
score: 0
Accepted
time: 227ms
memory: 15816kb
Test #71:
score: 0
Accepted
time: 265ms
memory: 15944kb
Test #72:
score: 0
Accepted
time: 262ms
memory: 15956kb
Test #73:
score: 0
Accepted
time: 3ms
memory: 14704kb
Test #74:
score: 0
Accepted
time: 0ms
memory: 14772kb
Test #75:
score: 0
Accepted
time: 0ms
memory: 14816kb
Test #76:
score: 0
Accepted
time: 15ms
memory: 14980kb
Test #77:
score: 0
Accepted
time: 23ms
memory: 14908kb
Test #78:
score: 0
Accepted
time: 23ms
memory: 14948kb
Test #79:
score: 0
Accepted
time: 22ms
memory: 15276kb
Test #80:
score: 0
Accepted
time: 141ms
memory: 15956kb
Test #81:
score: 0
Accepted
time: 267ms
memory: 15812kb
Test #82:
score: 0
Accepted
time: 275ms
memory: 15964kb
Test #83:
score: 0
Accepted
time: 273ms
memory: 15952kb
Test #84:
score: 0
Accepted
time: 272ms
memory: 15932kb