QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770458 | #9778. Brotato | PlentyOfPenalty# | WA | 2645ms | 332116kb | C++20 | 1.7kb | 2024-11-21 21:58:24 | 2024-11-21 21:58:33 |
Judging History
answer
#include <bits/stdc++.h>
#include <linux/limits.h>
#define sz(x) ((int)(x).size())
#define all(x) begin(x), end(x)
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define endl '\n'
#define log(...) (void(0))
#endif
using namespace std;
using ll = long long;
using lf = long double;
using ull = unsigned long long;
using lll = __int128;
const lf eps = 1e-10;
const int N = 100000, M = 100;
int n, K;
int pos[N + 10];
lf f[N + 10][M + 5], k[N + 10][M + 5];
lf p;
bool le(lf x, lf y) { return x - y < eps; }
bool eq(lf x, lf y) { return abs(x - y) < eps; }
lf Getfn(int be, int j, int x) {
// log("Get %d %d\n", j, x);
for (int i = be + 1; i <= n; ++i) {
f[i][j] = k[i][j] = 0;
}
for (int i = be + 1; i <= n; ++i) {
if (i <= x) f[i][j] = 1 + (1 - p) * f[i - 1][j] + p * f[i][j - 1];
else
f[i][j] = 1 + (1 - p) * f[i - 1][j], k[i][j] = (1 - p) * k[i - 1][j] + p;
}
f[n][j] /= (1 - k[n][j]);
for (int i = x + 1; i < n; ++i) f[i][j] += k[i][j] * f[n][j];
// for (int i = 1; i <= n; ++i) {
// log("%2.5Lf%c", f[i][j], " \n"[i == n]);
// }
return f[n][j];
}
int main() {
#ifdef memset0
freopen("K.in", "r", stdin);
#endif
cin.tie(0)->sync_with_stdio(0);
cin >> n >> K >> p;
K = min(K, 80);
Getfn(0, 0, 0);
for (int j = 1; j <= K; ++j) {
Getfn(0, j, pos[j - 1]);
int l = pos[j - 1], r = n, mid;
while (l < r) {
mid = (l + r >> 1);
if (le(Getfn(pos[j - 1], j, mid), Getfn(pos[j - 1], j, mid + 1))) r = mid;
else
l = mid + 1;
}
Getfn(pos[j - 1], j, l);
pos[j] = l;
// log("pos in %d=%d\n", j, pos[j]);
}
cout << fixed << setprecision(10) << f[n][K] << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5920kb
input:
5 0 0.5
output:
62.0000000000
result:
ok found '62.000000000', expected '62.000000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5924kb
input:
5 1 0.5
output:
47.0000000000
result:
ok found '47.000000000', expected '47.000000000', error '0.000000000'
Test #3:
score: 0
Accepted
time: 3ms
memory: 39044kb
input:
10000 0 0.002
output:
247489700306.9192301482
result:
ok found '247489700306.919219971', expected '247489700298.253692627', error '0.000000000'
Test #4:
score: 0
Accepted
time: 792ms
memory: 332012kb
input:
100000 10 0.0002
output:
38767507134.4257206172
result:
ok found '38767507134.425720215', expected '38767507133.232215881', error '0.000000000'
Test #5:
score: 0
Accepted
time: 11ms
memory: 332020kb
input:
100000 0 0.0002
output:
2430683127369.9571905136
result:
ok found '2430683127369.957031250', expected '2430683127170.376953125', error '0.000000000'
Test #6:
score: 0
Accepted
time: 1652ms
memory: 331876kb
input:
100000 20 0.0002
output:
801073272.2508440298
result:
ok found '801073272.250844002', expected '801073272.231680870', error '0.000000000'
Test #7:
score: 0
Accepted
time: 2645ms
memory: 332000kb
input:
100000 40 0.0002
output:
478148.7184351859
result:
ok found '478148.718435186', expected '478148.718426307', error '0.000000000'
Test #8:
score: 0
Accepted
time: 384ms
memory: 332012kb
input:
99995 4 0.0001
output:
38976542.8681762246
result:
ok found '38976542.868176222', expected '38976542.868175834', error '0.000000000'
Test #9:
score: 0
Accepted
time: 749ms
memory: 331996kb
input:
99995 10 0.0001
output:
3549184.5977120501
result:
ok found '3549184.597712050', expected '3549184.597712017', error '0.000000000'
Test #10:
score: 0
Accepted
time: 1044ms
memory: 332068kb
input:
99995 16 0.0001
output:
399507.4705567450
result:
ok found '399507.470556745', expected '399507.470556742', error '0.000000000'
Test #11:
score: 0
Accepted
time: 506ms
memory: 332008kb
input:
99990 8 0.0001
output:
7773463.9479307963
result:
ok found '7773463.947930796', expected '7773463.947930722', error '0.000000000'
Test #12:
score: 0
Accepted
time: 574ms
memory: 332116kb
input:
99990 10 0.0001
output:
3547428.9454723300
result:
ok found '3547428.945472330', expected '3547428.945472297', error '0.000000000'
Test #13:
score: 0
Accepted
time: 693ms
memory: 332000kb
input:
99990 12 0.0001
output:
1647102.0204344108
result:
ok found '1647102.020434411', expected '1647102.020434395', error '0.000000000'
Test #14:
score: 0
Accepted
time: 12ms
memory: 60532kb
input:
16664 1 0.0012
output:
257920044611.3729276806
result:
ok found '257920044611.372924805', expected '257920044630.860534668', error '0.000000000'
Test #15:
score: 0
Accepted
time: 151ms
memory: 60772kb
input:
16664 21 0.0012
output:
92190688.5446795048
result:
ok found '92190688.544679508', expected '92190688.544415027', error '0.000000000'
Test #16:
score: 0
Accepted
time: 194ms
memory: 63780kb
input:
16664 41 0.0012
output:
59865.0917860821
result:
ok found '59865.091786082', expected '59865.091785920', error '0.000000000'
Test #17:
score: 0
Accepted
time: 28ms
memory: 61196kb
input:
16659 5 0.0003
output:
63366.2644069548
result:
ok found '63366.264406955', expected '63366.264406955', error '0.000000000'
Test #18:
score: 0
Accepted
time: 38ms
memory: 60668kb
input:
16659 11 0.0003
output:
18120.9118635425
result:
ok found '18120.911863543', expected '18120.911863543', error '0.000000000'
Test #19:
score: 0
Accepted
time: 44ms
memory: 63932kb
input:
16659 17 0.0003
output:
16666.5554519674
result:
ok found '16666.555451967', expected '16666.555451967', error '0.000000000'
Test #20:
score: 0
Accepted
time: 13ms
memory: 63520kb
input:
16654 9 0.0001
output:
16656.0794165756
result:
ok found '16656.079416576', expected '16656.079416576', error '0.000000000'
Test #21:
score: 0
Accepted
time: 15ms
memory: 61148kb
input:
16654 11 0.0001
output:
16655.6741221724
result:
ok found '16655.674122172', expected '16655.674122172', error '0.000000000'
Test #22:
score: 0
Accepted
time: 15ms
memory: 61932kb
input:
16654 13 0.0001
output:
16655.6656953627
result:
ok found '16655.665695363', expected '16655.665695363', error '0.000000000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 16888kb
input:
2774 2 0.0072
output:
28951389307.2939606868
result:
ok found '28951389307.293960571', expected '28951389306.987514496', error '0.000000000'
Test #24:
score: 0
Accepted
time: 13ms
memory: 15644kb
input:
2774 22 0.0072
output:
11312241.4506332640
result:
ok found '11312241.450633263', expected '11312241.450653942', error '0.000000000'
Test #25:
score: 0
Accepted
time: 19ms
memory: 18524kb
input:
2774 42 0.0072
output:
8222.4151084981
result:
ok found '8222.415108498', expected '8222.415108509', error '0.000000000'
Test #26:
score: 0
Accepted
time: 6ms
memory: 18512kb
input:
2769 6 0.0021
output:
13600.5823557316
result:
ok found '13600.582355732', expected '13600.582355732', error '0.000000000'
Test #27:
score: 0
Accepted
time: 7ms
memory: 15796kb
input:
2769 12 0.0021
output:
3239.5499782111
result:
ok found '3239.549978211', expected '3239.549978211', error '0.000000000'
Test #28:
score: 0
Accepted
time: 3ms
memory: 15736kb
input:
2769 18 0.0021
output:
2776.6281948752
result:
ok found '2776.628194875', expected '2776.628194875', error '0.000000000'
Test #29:
score: 0
Accepted
time: 5ms
memory: 16156kb
input:
2764 10 0.0007
output:
2765.9870739551
result:
ok found '2765.987073955', expected '2765.987073955', error '0.000000000'
Test #30:
score: 0
Accepted
time: 4ms
memory: 14660kb
input:
2764 12 0.0007
output:
2765.9373628500
result:
ok found '2765.937362850', expected '2765.937362850', error '0.000000000'
Test #31:
score: 0
Accepted
time: 4ms
memory: 15152kb
input:
2764 14 0.0007
output:
2765.9361767035
result:
ok found '2765.936176704', expected '2765.936176704', error '0.000000000'
Test #32:
score: 0
Accepted
time: 1267ms
memory: 332004kb
input:
100000 1000000000 0.0001
output:
100010.0010001001
result:
ok found '100010.001000100', expected '100010.001000100', error '0.000000000'
Test #33:
score: 0
Accepted
time: 0ms
memory: 5968kb
input:
1 1000000000 0.5
output:
2.0000000000
result:
ok found '2.000000000', expected '2.000000000', error '0.000000000'
Test #34:
score: 0
Accepted
time: 1ms
memory: 6100kb
input:
50 50 0.25
output:
66.7341873337
result:
ok found '66.734187334', expected '66.734187334', error '0.000000000'
Test #35:
score: -100
Wrong Answer
time: 1ms
memory: 6088kb
input:
40 100 0.5
output:
47904.3425886479
result:
wrong answer 1st numbers differ - expected: '788.6331240', found: '47904.3425886', error = '59.7435081'