QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#783201 | #6264. Lucky Draw | 353cerega# | AC ✓ | 1ms | 4080kb | C++14 | 1.2kb | 2024-11-26 01:19:07 | 2024-11-26 01:19:08 |
Judging History
answer
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define X first
#define Y second
const ll mod = 1000000007;
//const ll mod = 998244353;
ll pew(ll a, ll b) {
ll res = 1;
while (b>0) {
if (b&1) res = res*a%mod;
b >>= 1;
a = a*a%mod;
}
return res;
}
void solve() {
ll n, k;
cin >> n >> k;
ld P;
cin >> P;
vector<ld> dp(k+1);
dp[k] = 1;
cout.precision(20);
ld A = 0;
for (ll i=0;;i++) {
vector<ld> dp2(k+1);
for (ll j=1;j<=k;j++) {
dp2[j] += dp[j]*P;
dp2[j-1] += dp[j]*(1-P);
}
ld S2 = 0;
for (ll j=0;j<=k;j++) {
S2 += dp2[j];
}
ld S = dp2[0];
for (ll j=0;j+1<n;j++) {
S *= (1-S2);
}
A += S*n;
if (S2<1e-12) break;
dp = dp2;
}
cout << 1-A << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
int T = 1;
//cin >> T;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
2 2 0.5
output:
0.18518518518586730612
result:
ok found '0.1851852', expected '0.1851852', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 2 0.8
output:
0.0562414266133674397
result:
ok found '0.0562414', expected '0.0562414', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
5 3 0.85
output:
0.045463964055866902298
result:
ok found '0.0454640', expected '0.0454640', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4080kb
input:
10 1 0.1
output:
0.55918650223900890619
result:
ok found '0.5591865', expected '0.5591865', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
10 1 0.5
output:
0.27875434254904016068
result:
ok found '0.2787543', expected '0.2787543', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3988kb
input:
10 1 0.9
output:
0.05087784191231308487
result:
ok found '0.0508778', expected '0.0508778', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 4048kb
input:
10 2 0.1
output:
0.5327341098202815051
result:
ok found '0.5327341', expected '0.5327341', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
10 2 0.5
output:
0.22689089967044007157
result:
ok found '0.2268909', expected '0.2268909', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
10 2 0.9
output:
0.039164907554435558605
result:
ok found '0.0391649', expected '0.0391649', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
10 3 0.1
output:
0.5230588549228802549
result:
ok found '0.5230589', expected '0.5230589', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
10 3 0.5
output:
0.19936735604031325829
result:
ok found '0.1993674', expected '0.1993674', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
10 3 0.9
output:
0.03359530245436911
result:
ok found '0.0335953', expected '0.0335953', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
10 50 0.1
output:
0.23125099168682856649
result:
ok found '0.2312510', expected '0.2312510', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 4048kb
input:
10 50 0.5
output:
0.067095817214477851799
result:
ok found '0.0670958', expected '0.0670958', error '0.0000000'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
10 50 0.9
output:
0.010357150282397231168
result:
ok found '0.0103572', expected '0.0103572', error '0.0000000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 1 0.1
output:
0.81818181818183818182
result:
ok found '0.8181818', expected '0.8181818', error '0.0000000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 1 0.5
output:
0.33333333333424282802
result:
ok found '0.3333333', expected '0.3333333', error '0.0000000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 1 0.9
output:
0.052631578949032034695
result:
ok found '0.0526316', expected '0.0526316', error '0.0000000'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
2 2 0.1
output:
0.68294515401956318475
result:
ok found '0.6829452', expected '0.6829452', error '0.0000000'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 2 0.5
output:
0.18518518518586730612
result:
ok found '0.1851852', expected '0.1851852', error '0.0000000'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 2 0.9
output:
0.026388686399181998882
result:
ok found '0.0263887', expected '0.0263887', error '0.0000000'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
2 3 0.1
output:
0.58123824130266796729
result:
ok found '0.5812382', expected '0.5812382', error '0.0000000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
2 3 0.5
output:
0.1358024691364148681
result:
ok found '0.1358025', expected '0.1358025', error '0.0000000'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
2 3 0.9
output:
0.019773442016714432587
result:
ok found '0.0197734', expected '0.0197734', error '0.0000000'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
2 50 0.1
output:
0.11565897571257403674
result:
ok found '0.1156590', expected '0.1156590', error '0.0000000'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
2 50 0.5
output:
0.028441646001678555576
result:
ok found '0.0284416', expected '0.0284416', error '0.0000000'
Test #27:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
2 50 0.9
output:
0.0042371527177815778787
result:
ok found '0.0042372', expected '0.0042372', error '0.0000000'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
3 1 0.1
output:
0.7518427518427818428
result:
ok found '0.7518428', expected '0.7518428', error '0.0000000'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
3 1 0.5
output:
0.28571428571564995636
result:
ok found '0.2857143', expected '0.2857143', error '0.0000000'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
3 1 0.9
output:
0.0508836667338995771
result:
ok found '0.0508837', expected '0.0508837', error '0.0000000'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
3 2 0.1
output:
0.60123357513431031169
result:
ok found '0.6012336', expected '0.6012336', error '0.0000000'
Test #32:
score: 0
Accepted
time: 0ms
memory: 4048kb
input:
3 2 0.5
output:
0.19612198621047294782
result:
ok found '0.1961220', expected '0.1961220', error '0.0000000'
Test #33:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
3 2 0.9
output:
0.031797391961718812217
result:
ok found '0.0317974', expected '0.0317974', error '0.0000000'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
3 3 0.1
output:
0.50816955125477742794
result:
ok found '0.5081696', expected '0.5081696', error '0.0000000'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
3 3 0.5
output:
0.1599825613468574487
result:
ok found '0.1599826', expected '0.1599826', error '0.0000000'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
3 3 0.9
output:
0.025228578436877428478
result:
ok found '0.0252286', expected '0.0252286', error '0.0000000'
Test #37:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
3 50 0.1
output:
0.15611940819880401686
result:
ok found '0.1561194', expected '0.1561194', error '0.0000000'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
3 50 0.5
output:
0.040793505631925281883
result:
ok found '0.0407935', expected '0.0407935', error '0.0000000'
Test #39:
score: 0
Accepted
time: 1ms
memory: 3816kb
input:
3 50 0.9
output:
0.0061485939678357125009
result:
ok found '0.0061486', expected '0.0061486', error '0.0000000'
Test #40:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
50 1 0.1
output:
0.65140348564199518697
result:
ok found '0.6514035', expected '0.6514035', error '0.0000000'
Test #41:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
50 1 0.5
output:
0.27864707311292057545
result:
ok found '0.2786471', expected '0.2786471', error '0.0000000'
Test #42:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
50 1 0.9
output:
0.050877841938600039851
result:
ok found '0.0508778', expected '0.0508778', error '0.0000000'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
50 2 0.1
output:
0.53994943847777845193
result:
ok found '0.5399494', expected '0.5399494', error '0.0000000'
Test #44:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
50 2 0.5
output:
0.24339566149684222504
result:
ok found '0.2433957', expected '0.2433957', error '0.0000000'
Test #45:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
50 2 0.9
output:
0.042963475845005544697
result:
ok found '0.0429635', expected '0.0429635', error '0.0000000'
Test #46:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
50 3 0.1
output:
0.54337280952053131403
result:
ok found '0.5433728', expected '0.5433728', error '0.0000000'
Test #47:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
50 3 0.5
output:
0.22205710156214740388
result:
ok found '0.2220571', expected '0.2220571', error '0.0000000'
Test #48:
score: 0
Accepted
time: 0ms
memory: 4056kb
input:
50 3 0.9
output:
0.038478423141390988098
result:
ok found '0.0384784', expected '0.0384784', error '0.0000000'
Test #49:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
50 50 0.1
output:
0.28682443222566981973
result:
ok found '0.2868244', expected '0.2868244', error '0.0000000'
Test #50:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
50 50 0.5
output:
0.08950023709848401555
result:
ok found '0.0895002', expected '0.0895002', error '0.0000000'
Test #51:
score: 0
Accepted
time: 1ms
memory: 3924kb
input:
50 50 0.9
output:
0.014085652154824761999
result:
ok found '0.0140857', expected '0.0140857', error '0.0000000'