QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770443 | #9778. Brotato | PlentyOfPenalty# | TL | 2097ms | 332100kb | C++20 | 1.7kb | 2024-11-21 21:55:20 | 2024-11-21 21:55:20 |
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;
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: 5924kb
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: 0ms
memory: 5984kb
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: 0ms
memory: 39088kb
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: 698ms
memory: 332092kb
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: 19ms
memory: 332052kb
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: 1303ms
memory: 332016kb
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: 2097ms
memory: 331868kb
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: 349ms
memory: 332100kb
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: 605ms
memory: 332052kb
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: 1357ms
memory: 332008kb
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: 642ms
memory: 331984kb
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: 619ms
memory: 331980kb
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: 878ms
memory: 332096kb
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: 7ms
memory: 60556kb
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: 127ms
memory: 61064kb
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: 172ms
memory: 61248kb
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: 26ms
memory: 60832kb
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: 41ms
memory: 60232kb
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: 38ms
memory: 60252kb
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: 11ms
memory: 60488kb
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: 17ms
memory: 61996kb
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: 18ms
memory: 63880kb
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: 16704kb
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: 14ms
memory: 15684kb
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: 15480kb
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: 0ms
memory: 15840kb
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: 8ms
memory: 16048kb
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: 8ms
memory: 15140kb
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: 15828kb
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: 0ms
memory: 15248kb
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: 0ms
memory: 15828kb
input:
2764 14 0.0007
output:
2765.9361767035
result:
ok found '2765.936176704', expected '2765.936176704', error '0.000000000'
Test #32:
score: -100
Time Limit Exceeded
input:
100000 1000000000 0.0001