QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#586473 | #9283. Socks Drying | alex_china | AC ✓ | 8ms | 4308kb | C++14 | 935b | 2024-09-24 13:03:15 | 2024-09-24 13:03:16 |
Judging History
answer
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
const int N=5e5+5;
double f[15][15];
double g[15][15];
int a[N],cnt[N];
double calc(int x,int y)
{
if(!y)return 0;
if(!x)return 1.0;
else return 0.5;
}
double get(int n,int m)
{
rep(i,0,n+1)rep(j,0,m+1)f[i][j]=0.0;f[0][0]=1.0;
double tot=0;
rep(i,0,n)rep(j,0,m)
{
int w1=n-i,w2=m-j;
if(!w1 && !w2)continue;
f[i+1][j]+=1.0*w1/(w1+w2)*f[i][j];
f[i][j+1]+=1.0*w2/(w1+w2)*f[i][j];
if(i<n)tot+=1.0*1.0*w1/(w1+w2)*f[i][j]*calc(i%2,j%2);
}
return tot;
}
int main()
{
rep(i,1,5)rep(j,1,5)g[i][j]=get(i*2,j*2);
int n;scanf("%d",&n);
double ans=0;
rep(i,1,n)scanf("%d",&a[i]),cnt[a[i]]++;
rep(i,1,n)ans+=a[i]*3.0;
rep(i,1,5)rep(j,i+1,5)if(i!=j)ans+=1.0*cnt[i]*cnt[j]*(g[i][j]+g[j][i]);
rep(i,1,5)ans+=1.0*cnt[i]*(cnt[i]-1)*g[i][i];
printf("%.9lf\n",ans);
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3704kb
input:
1 1
output:
3.000000000
result:
ok found '3.0000000', expected '3.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
1 3
output:
9.000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
2 1 1
output:
7.000000000
result:
ok found '7.0000000', expected '7.0000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
3 3 2 2
output:
29.571428571
result:
ok found '29.5714286', expected '29.5714286', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
15 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
output:
662.340259740
result:
ok found '662.3402597', expected '662.3402597', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 1616kb
input:
25 1 1 4 3 3 3 2 5 1 4 4 2 5 5 3 5 2 4 2 1 2 5 1 3 4
output:
1335.731601732
result:
ok found '1335.7316017', expected '1335.7316017', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
50 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5
output:
4989.969696970
result:
ok found '4989.9696970', expected '4989.9696970', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
500 4 3 3 3 4 5 1 4 4 4 1 3 4 2 3 3 1 2 2 2 1 5 5 2 2 2 4 2 5 3 2 3 3 5 3 1 1 1 1 2 5 1 5 1 2 1 1 3 4 5 3 4 1 1 4 1 3 2 1 4 4 5 1 1 5 3 4 2 4 3 5 2 2 4 3 5 2 5 4 5 5 2 2 1 2 4 2 1 5 3 1 5 1 4 2 2 2 5 1 3 2 2 5 4 2 4 2 5 4 3 1 3 3 4 3 1 3 1 5 3 5 2 2 2 1 4 2 3 4 3 3 1 5 4 2 4 1 5 3 5 3 3 4 4 5 1 5 2 ...
output:
467230.865800866
result:
ok found '467230.8658009', expected '467230.8658009', error '0.0000000'
Test #9:
score: 0
Accepted
time: 8ms
memory: 3668kb
input:
200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
20000500000.000000000
result:
ok found '20000500000.0000000', expected '20000500000.0000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
10000 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...
output:
341025000.000000000
result:
ok found '341025000.0000000', expected '341025000.0000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 8ms
memory: 3628kb
input:
200000 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5...
output:
136365954545.454544067
result:
ok found '136365954545.4545441', expected '136365954545.4545441', error '0.0000000'
Test #12:
score: 0
Accepted
time: 8ms
memory: 4308kb
input:
200000 4 4 4 4 4 4 4 4 5 4 5 5 4 5 5 4 4 5 4 4 4 5 4 5 4 5 5 5 5 4 4 5 4 4 5 4 5 5 4 4 5 4 5 5 4 5 5 5 5 4 4 5 5 5 4 4 5 5 5 5 5 4 5 4 5 4 4 5 4 4 5 5 4 5 4 4 4 5 4 4 4 5 5 5 4 4 5 5 4 4 5 4 4 5 4 5 5 5 5 4 5 4 4 5 4 5 5 5 4 5 5 5 4 5 4 5 4 4 4 5 5 4 4 5 4 4 4 5 4 5 4 4 4 4 5 4 4 4 5 4 4 4 4 5 5 5 5...
output:
121365728787.878784180
result:
ok found '121365728787.8787842', expected '121365728787.8787842', error '0.0000000'
Test #13:
score: 0
Accepted
time: 6ms
memory: 3656kb
input:
150002 1 1 1 2 3 1 2 3 1 1 1 2 3 2 2 2 1 1 3 2 2 2 2 1 3 2 1 1 2 2 3 3 1 3 2 3 2 3 2 3 1 1 2 1 2 3 2 1 1 2 3 1 2 2 2 2 2 1 3 1 2 2 2 1 3 3 3 1 3 3 2 2 2 3 2 2 3 2 2 1 2 3 3 3 2 2 1 1 2 1 1 1 2 3 3 1 3 2 1 1 2 3 2 1 2 1 1 3 3 2 3 1 1 1 2 3 1 2 3 1 1 2 3 2 3 2 2 2 2 1 3 1 1 3 3 3 3 1 2 3 1 2 2 2 2 1 2...
output:
26144672886.476188660
result:
ok found '26144672886.4761887', expected '26144672886.4761887', error '0.0000000'
Test #14:
score: 0
Accepted
time: 8ms
memory: 3664kb
input:
200000 5 5 5 5 5 5 5 5 5 5 3 4 5 4 4 5 5 5 4 3 5 4 4 3 3 5 5 5 5 5 5 5 3 5 5 4 3 4 3 4 3 5 3 5 4 3 5 4 3 4 5 3 5 3 3 4 4 3 5 3 5 5 5 5 5 5 5 3 5 5 5 4 3 3 5 3 5 3 5 3 5 5 5 3 5 5 5 4 3 4 5 5 3 4 5 4 3 4 5 5 4 5 5 3 4 4 5 5 3 3 5 4 5 3 4 3 5 4 5 5 3 4 5 4 3 4 5 3 5 5 4 3 3 5 5 3 4 5 5 5 4 5 5 4 4 4 4...
output:
113611286688.311676025
result:
ok found '113611286688.3116760', expected '113611286688.3116913', error '0.0000000'
Test #15:
score: 0
Accepted
time: 4ms
memory: 3644kb
input:
200000 2 3 2 2 2 3 3 2 5 5 2 3 2 3 2 5 3 4 4 4 4 5 5 4 4 4 5 4 4 3 3 3 3 5 3 5 3 2 5 3 2 3 3 5 4 4 5 3 2 4 4 4 4 5 5 4 5 2 3 3 5 3 4 2 3 2 5 3 4 2 3 3 4 4 3 4 3 3 5 5 2 5 5 4 5 3 2 4 4 4 3 4 5 3 4 5 3 3 4 2 3 3 5 5 3 3 3 4 4 2 4 3 3 4 3 2 4 4 4 4 3 5 5 4 4 4 3 5 5 2 5 3 5 3 4 2 3 5 2 5 4 5 4 4 2 5 5...
output:
90698609480.519470215
result:
ok found '90698609480.5194702', expected '90698609480.5194855', error '0.0000000'
Test #16:
score: 0
Accepted
time: 8ms
memory: 3652kb
input:
200000 1 2 5 1 1 3 5 3 2 3 3 2 2 2 4 5 3 1 3 3 1 3 5 2 2 3 4 2 5 3 4 5 2 5 2 3 2 4 1 5 3 5 3 4 4 1 3 1 2 3 4 3 3 4 2 5 5 4 5 1 2 5 3 4 3 3 2 2 2 1 2 5 5 3 3 5 5 5 2 2 3 1 5 4 4 5 5 2 4 5 2 5 4 3 2 1 5 5 3 5 1 4 1 2 5 4 1 5 2 2 1 2 3 5 4 4 1 4 2 3 2 1 4 1 4 5 1 5 4 1 5 4 4 4 4 4 4 5 3 2 5 3 2 4 4 5 1...
output:
74193619619.047607422
result:
ok found '74193619619.0476074', expected '74193619619.0476227', error '0.0000000'
Test #17:
score: 0
Accepted
time: 8ms
memory: 2436kb
input:
200000 3 5 5 1 4 3 3 3 5 5 3 4 2 1 5 1 1 4 4 2 4 3 3 5 1 5 5 2 1 4 3 2 3 3 4 4 3 3 5 5 3 5 5 4 3 3 3 2 4 1 3 2 2 2 4 3 5 1 3 3 2 3 1 4 3 3 2 5 2 2 1 2 4 1 2 3 2 4 5 4 2 3 5 4 2 4 4 2 1 5 3 2 1 5 1 4 4 1 5 1 2 3 5 4 1 5 3 3 4 1 5 5 1 1 4 4 3 5 4 2 5 4 4 5 1 1 3 4 1 4 3 2 3 5 5 4 1 2 1 3 1 3 4 4 5 4 5...
output:
74191942588.000000000
result:
ok found '74191942588.0000000', expected '74191942588.0000000', error '0.0000000'
Test #18:
score: 0
Accepted
time: 8ms
memory: 3840kb
input:
200000 1 3 2 4 4 5 3 3 5 3 5 1 3 2 2 4 5 5 4 5 5 1 4 3 1 3 5 4 2 1 2 3 2 4 3 3 5 4 5 5 1 2 4 2 5 3 2 2 5 4 4 5 5 4 4 3 3 5 1 5 1 3 4 5 5 4 4 3 3 4 1 5 5 5 2 3 4 2 2 5 5 4 3 3 5 5 5 4 5 4 3 5 5 5 4 3 4 1 4 4 5 5 4 4 5 5 4 3 3 5 4 5 3 2 4 3 5 3 4 5 5 1 4 3 4 3 2 1 1 5 5 2 4 5 2 5 4 4 3 3 1 5 4 5 4 1 5...
output:
89542084593.272720337
result:
ok found '89542084593.2727203', expected '89542084593.2727203', error '0.0000000'
Test #19:
score: 0
Accepted
time: 5ms
memory: 3724kb
input:
199999 4 3 1 5 1 4 3 3 5 5 1 4 3 4 1 4 5 4 3 3 5 4 3 4 4 5 4 5 4 3 1 1 5 3 4 1 3 4 1 3 1 3 1 5 3 1 1 5 4 1 5 4 4 3 1 4 4 4 1 3 3 5 5 1 5 3 4 1 4 3 3 1 5 3 3 3 1 4 3 4 4 4 3 5 4 5 3 1 4 5 3 4 4 1 4 5 3 4 1 1 3 4 3 5 4 5 4 5 3 1 5 5 5 1 3 4 5 1 4 4 5 5 3 5 5 3 1 4 4 4 4 3 5 1 4 1 5 5 5 4 3 3 1 1 4 1 4...
output:
80967504849.428558350
result:
ok found '80967504849.4285583', expected '80967504849.4285736', error '0.0000000'
Test #20:
score: 0
Accepted
time: 8ms
memory: 3692kb
input:
200000 5 1 1 5 1 5 5 5 1 1 5 5 5 1 5 5 5 5 1 1 5 5 5 5 1 1 5 5 1 5 5 1 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 1 5 5 5 1 1 5 5 5 5 5 5 1 5 5 5 1 1 1 5 5 1 5 5 5 5 5 5 5 1 5 5 5 5 5 5 5 5 5 1 5 5 5 5 1 5 5 5 1 5 5 5 5 5 1 5 5 1 5 1 1 5 1 5 5 1 5 5 1 5 1 5 5 1 1 5 5 5 1 5 5 5 5 1 1 5 5 1 5 5 5 5 5...
output:
101817807677.834625244
result:
ok found '101817807677.8346252', expected '101817807677.8346252', error '0.0000000'
Test #21:
score: 0
Accepted
time: 8ms
memory: 4000kb
input:
199999 4 2 4 4 4 4 4 2 2 4 4 4 2 4 4 2 4 4 4 2 2 2 4 2 4 4 4 4 4 4 2 4 4 2 4 4 4 4 4 2 4 4 2 4 4 4 4 2 4 4 4 4 4 4 4 2 4 2 4 4 2 4 2 2 4 4 4 4 4 4 4 4 4 2 2 4 4 4 2 2 4 4 4 4 4 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 4 4 4 4 4 4 4 4 2 4 4 2 4 4 2 4 2 4 4 4 4 4 4 4 4 2 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2...
output:
91000121202.024230957
result:
ok found '91000121202.0242310', expected '91000121202.0242462', error '0.0000000'
Extra Test:
score: 0
Extra Test Passed