QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#63853 | #5105. Hand of the Free Marked | Qingyu | AC ✓ | 50ms | 3612kb | C++ | 1014b | 2022-11-23 14:51:53 | 2022-11-23 14:51:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;
const int MAXD = 10 + 5;
ldb C(int n,int m)
{
ldb res = 0;
for(int i=0; i<m; ++i)
res = res + logl(n-i) - logl(i+1);
return res;
}
int d, m;
int a[MAXD];
ldb ans = 0, tot = 0;
int use[MAXD];
void dfs(int dep,int has)
{
if(dep>m)
{
if(has != d) return;
ldb A = 0;
for(int i=1; i<=m; ++i)
A += C(a[i], use[i]);
ldb B = 0;
for(int i=1; i<=m; ++i) if(use[i])
{
B += (ldb)use[i] / (a[i] - use[i] + 1);
}
B = logl(B);
B += A;
for(int i=1; i<d; ++i)
B += logl(i);
ans += expl(min(A,B) - tot);
return;
}
for(int i=0; has+i<=d && i<=a[dep]; ++i)
use[dep] = i, dfs(dep+1, has+i);
}
int main(void)
{
scanf("%d%d",&d,&m);
for(int i=1; i<=m; ++i)
scanf("%d",&a[i]);
int n = accumulate(a+1,a+m+1,0);
tot = C(n, d);
dfs(1,0);
printf("%.20lf\n",(double)ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3476kb
input:
3 3 2 1 2
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #2:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
3 4 1 3 1 15
output:
0.77192982456140346592
result:
ok answer is 0.7719298246
Test #3:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
4 1 27
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #4:
score: 0
Accepted
time: 2ms
memory: 3464kb
input:
4 3 1 2 28
output:
0.97397107897664070286
result:
ok answer is 0.9739710790
Test #5:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
4 3 1 3 28
output:
0.97722469410456058725
result:
ok answer is 0.9772246941
Test #6:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
5 1 130
output:
0.95238095238095232808
result:
ok answer is 0.9523809524
Test #7:
score: 0
Accepted
time: 2ms
memory: 3472kb
input:
5 3 2 16 200
output:
0.74903921225342529056
result:
ok answer is 0.7490392123
Test #8:
score: 0
Accepted
time: 2ms
memory: 3580kb
input:
4 10 1 2 3 4 1 2 3 4 5 100
output:
0.69549986457030088527
result:
ok answer is 0.6954998646
Test #9:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
4 10 1 20 3 4 1 2 40 4 5 500
output:
0.24357218158421131693
result:
ok answer is 0.2435721816
Test #10:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
3 2 152333146 373955979
output:
0.00000002280115525017
result:
ok answer is 0.0000000228
Test #11:
score: 0
Accepted
time: 2ms
memory: 3464kb
input:
2 5 263121 2244976 14139709 57922752 200667899
output:
0.00000003633213230930
result:
ok answer is 0.0000000363
Test #12:
score: 0
Accepted
time: 2ms
memory: 3604kb
input:
2 9 8693409 192044828 270204 207696017 4714758 43866747 54411633 159493424 1230327
output:
0.00000002676893008688
result:
ok answer is 0.0000000268
Test #13:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
5 2 368946153 140852305
output:
0.00000047077427975095
result:
ok answer is 0.0000004708
Test #14:
score: 0
Accepted
time: 3ms
memory: 3464kb
input:
6 7 21894756 69672 6998541 209713 14912795 3044993 4001906
output:
0.00009856769599047148
result:
ok answer is 0.0000985677
Test #15:
score: 0
Accepted
time: 3ms
memory: 3464kb
input:
7 8 10393835 5758 42813 141353298 4827 7467584 30955 5450
output:
0.00025310017266679587
result:
ok answer is 0.0002531002
Test #16:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
9 2 510542963 107597808
output:
0.00117410150477327449
result:
ok answer is 0.0011741015
Test #17:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
9 4 61285845 5006573 857873 164342879
output:
0.00627025000418802818
result:
ok answer is 0.0062702500
Test #18:
score: 0
Accepted
time: 8ms
memory: 3556kb
input:
8 9 150817030 1785608 1799504 185570 765031 91189422 826565 162065 31840039
output:
0.00129891873069481220
result:
ok answer is 0.0012989187
Test #19:
score: 0
Accepted
time: 2ms
memory: 3500kb
input:
3 3 303536168 13837393 495002513
output:
0.00000002215722572390
result:
ok answer is 0.0000000222
Test #20:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
3 6 53418609 234629667 123823068 34111351 5030364 122184307
output:
0.00000006280559238580
result:
ok answer is 0.0000000628
Test #21:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
2 8 367991 173352184 277736038 8490 1609033 14778992 46849 7751
output:
0.00000003419480541710
result:
ok answer is 0.0000000342
Test #22:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
7 2 267723891 27011243
output:
0.00003420019889858531
result:
ok answer is 0.0000342002
Test #23:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
7 4 142414601 5258379 6663526 395635619
output:
0.00003665640366761937
result:
ok answer is 0.0000366564
Test #24:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
6 10 74360718 12028354 85290 298827 991561 26513484 13713894 241157 664292 69531
output:
0.00005582819054251378
result:
ok answer is 0.0000558282
Test #25:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
8 2 248584022 141021009
output:
0.00020697885045753414
result:
ok answer is 0.0002069789
Test #26:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
8 5 21702603 142314177 4721812 36026710 10702024
output:
0.00093564073166938139
result:
ok answer is 0.0009356407
Test #27:
score: 0
Accepted
time: 12ms
memory: 3528kb
input:
8 10 167779 219592785 89060 377095564 169349 75686 382454 10537801 86060 487630
output:
0.00066241250525985015
result:
ok answer is 0.0006624125
Test #28:
score: 0
Accepted
time: 2ms
memory: 3532kb
input:
2 1 2
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #29:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
2 1 1000000000
output:
0.00000000200000000200
result:
ok answer is 0.0000000020
Test #30:
score: 0
Accepted
time: 2ms
memory: 3464kb
input:
2 2 1 1
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #31:
score: 0
Accepted
time: 2ms
memory: 3604kb
input:
2 2 1 999999999
output:
0.00000000400000000000
result:
ok answer is 0.0000000040
Test #32:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
2 2 999999999 1
output:
0.00000000400000000000
result:
ok answer is 0.0000000040
Test #33:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
2 2 500000000 500000000
output:
0.00000000400000000400
result:
ok answer is 0.0000000040
Test #34:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
2 3 1 1 1
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #35:
score: 0
Accepted
time: 2ms
memory: 3460kb
input:
2 3 1 3 2
output:
0.93333333333333334814
result:
ok answer is 0.9333333333
Test #36:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
2 3 1 999999997 2
output:
0.00000000599999999800
result:
ok answer is 0.0000000060
Test #37:
score: 0
Accepted
time: 2ms
memory: 3464kb
input:
2 10 1 1 1 1 1 1 1 1 1 1
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #38:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
2 10 1 2 1 2 1 2 1 2 1 2
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #39:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
2 10 1 2 3 4 5 6 7 8 9 10
output:
0.36296296296296298722
result:
ok answer is 0.3629629630
Test #40:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
2 10 1 1 1 1 1 999999980 2 2 2 2
output:
0.00000002000000007200
result:
ok answer is 0.0000000200
Test #41:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
3 1 3
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #42:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
3 1 500000000
output:
0.00000001200000004800
result:
ok answer is 0.0000000120
Test #43:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
3 2 1 2
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #44:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
3 2 999999998 1
output:
0.00000000900000000900
result:
ok answer is 0.0000000090
Test #45:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
3 3 3 3 3
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #46:
score: 0
Accepted
time: 2ms
memory: 3612kb
input:
3 3 5 12 1
output:
0.79656862745098033773
result:
ok answer is 0.7965686275
Test #47:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
3 10 99999990 99999991 99999992 99999993 99999994 99999995 99999996 99999997 99999998 99999999
output:
0.00000006000000342000
result:
ok answer is 0.0000000600
Test #48:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
10 1 10
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #49:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
10 1 500000000
output:
0.00725760013063680206
result:
ok answer is 0.0072576001
Test #50:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
10 1 1000000000
output:
0.00362880003265920017
result:
ok answer is 0.0036288000
Test #51:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
10 2 5 5
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #52:
score: 0
Accepted
time: 2ms
memory: 3576kb
input:
10 2 10 5
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #53:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
10 2 999999999 1
output:
0.00362881000000000011
result:
ok answer is 0.0036288100
Test #54:
score: 0
Accepted
time: 3ms
memory: 3476kb
input:
10 2 500000000 500000000
output:
0.00725760006531840033
result:
ok answer is 0.0072576001
Test #55:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
10 2 499999999 500000001
output:
0.00725760006531840033
result:
ok answer is 0.0072576001
Test #56:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
10 3 10 10 10
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #57:
score: 0
Accepted
time: 2ms
memory: 3604kb
input:
10 3 11 10 10
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #58:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
10 3 11 999999970 10
output:
0.00362900937945822774
result:
ok answer is 0.0036290094
Test #59:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
10 3 499999990 2 499999999
output:
0.00725762000000008956
result:
ok answer is 0.0072576200
Test #60:
score: 0
Accepted
time: 2ms
memory: 3476kb
input:
10 3 333333333 333333333 333333333
output:
0.01088640010886400035
result:
ok answer is 0.0108864001
Test #61:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
10 10 1 1 1 1 1 1 1 1 1 1
output:
1.00000000000000000000
result:
ok answer is 1.0000000000
Test #62:
score: 0
Accepted
time: 50ms
memory: 3476kb
input:
10 10 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000
output:
0.03628800032659199731
result:
ok answer is 0.0362880003
Test #63:
score: 0
Accepted
time: 49ms
memory: 3500kb
input:
10 10 99999999 99999998 99999997 99999996 99999995 99999994 99999993 99999992 99999991 99999990
output:
0.03628800232243215018
result:
ok answer is 0.0362880023
Test #64:
score: 0
Accepted
time: 5ms
memory: 3472kb
input:
10 10 1 2 1 2 1 2 1 2 999999980 3
output:
0.00362894956090651895
result:
ok answer is 0.0036289496
Extra Test:
score: 0
Extra Test Passed