QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#564837#9283. Socks Dryingucup-team3161#AC ✓21ms4112kbC++141.4kb2024-09-15 15:19:062024-09-15 15:19:06

Judging History

你现在查看的是最新测评结果

  • [2024-09-15 15:19:06]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:4112kb
  • [2024-09-15 15:19:06]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,x,y) for (int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (int i=(x);i<(y);i++)
#define Dow(i,x,y) for (int i=(x);i>=(y);i--)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define fil(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
	ll x=0,f=1;char c=getchar();
	while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if (c=='-') f=-1,c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}

const int N = 2e5+10;
int n,c[10];
ll fac[22];

inline double calc(int x,int y){
	double ans=0;
	FOR(i,0,1<<(2*(x+y))) if (__builtin_popcount(i)==2*x){
		int f1=0,f2=0;
		FOR(j,0,2*(x+y)) if (i>>j&1){
			if (!f1){
				if (f2) ans+=1;
			} else {
				if (f2) ans+=0.5;
			}
			f1^=1;
		} else {
			if (!f2){
				if (f1) ans+=1;
			} else {
				if (f1) ans+=0.5;
			}
			f2^=1;	
		}
	}
	ans=ans*(1.0*fac[2*x]*fac[2*y]/fac[2*(x+y)]);
	return ans;
}

int main(){
	n=read();
	For(i,1,n) c[read()]++;
	fac[0]=1;
	For(i,1,20) fac[i]=fac[i-1]*i;
	double ans=0;
	For(i,1,5){
		ans+=calc(i,i)*(1ll*(c[i]-1)*c[i]/2);
		ans+=c[i]*i*3;
		For(j,i+1,5) ans+=calc(i,j)*c[i]*c[j];
	}
	printf("%0.12lf\n",ans);
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 20ms
memory: 3920kb

input:

1
1

output:

3.000000000000

result:

ok found '3.0000000', expected '3.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 20ms
memory: 3708kb

input:

1
3

output:

9.000000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 16ms
memory: 4108kb

input:

2
1 1

output:

7.000000000000

result:

ok found '7.0000000', expected '7.0000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 20ms
memory: 3884kb

input:

3
3 2 2

output:

29.571428571429

result:

ok found '29.5714286', expected '29.5714286', error '0.0000000'

Test #5:

score: 0
Accepted
time: 20ms
memory: 3944kb

input:

15
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

output:

662.340259740260

result:

ok found '662.3402597', expected '662.3402597', error '0.0000000'

Test #6:

score: 0
Accepted
time: 20ms
memory: 4112kb

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.731601731602

result:

ok found '1335.7316017', expected '1335.7316017', error '0.0000000'

Test #7:

score: 0
Accepted
time: 20ms
memory: 3940kb

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.969696969698

result:

ok found '4989.9696970', expected '4989.9696970', error '0.0000000'

Test #8:

score: 0
Accepted
time: 20ms
memory: 3880kb

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.865800865751

result:

ok found '467230.8658009', expected '467230.8658009', error '0.0000000'

Test #9:

score: 0
Accepted
time: 17ms
memory: 3984kb

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.000000000000

result:

ok found '20000500000.0000000', expected '20000500000.0000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 16ms
memory: 3880kb

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.000000000000

result:

ok found '341025000.0000000', expected '341025000.0000000', error '0.0000000'

Test #11:

score: 0
Accepted
time: 21ms
memory: 3768kb

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.454544067383

result:

ok found '136365954545.4545441', expected '136365954545.4545441', error '0.0000000'

Test #12:

score: 0
Accepted
time: 21ms
memory: 4016kb

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.878784179688

result:

ok found '121365728787.8787842', expected '121365728787.8787842', error '0.0000000'

Test #13:

score: 0
Accepted
time: 20ms
memory: 3756kb

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.476188659668

result:

ok found '26144672886.4761887', expected '26144672886.4761887', error '0.0000000'

Test #14:

score: 0
Accepted
time: 21ms
memory: 3764kb

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.311676025391

result:

ok found '113611286688.3116760', expected '113611286688.3116913', error '0.0000000'

Test #15:

score: 0
Accepted
time: 21ms
memory: 3980kb

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.519470214844

result:

ok found '90698609480.5194702', expected '90698609480.5194855', error '0.0000000'

Test #16:

score: 0
Accepted
time: 21ms
memory: 4052kb

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.047607421875

result:

ok found '74193619619.0476074', expected '74193619619.0476227', error '0.0000000'

Test #17:

score: 0
Accepted
time: 21ms
memory: 3708kb

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.000000000000

result:

ok found '74191942588.0000000', expected '74191942588.0000000', error '0.0000000'

Test #18:

score: 0
Accepted
time: 21ms
memory: 3884kb

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.272735595703

result:

ok found '89542084593.2727356', expected '89542084593.2727203', error '0.0000000'

Test #19:

score: 0
Accepted
time: 21ms
memory: 3876kb

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.428573608398

result:

ok found '80967504849.4285736', expected '80967504849.4285736', error '0.0000000'

Test #20:

score: 0
Accepted
time: 21ms
memory: 4020kb

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.834625244141

result:

ok found '101817807677.8346252', expected '101817807677.8346252', error '0.0000000'

Test #21:

score: 0
Accepted
time: 21ms
memory: 3760kb

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.024246215820

result:

ok found '91000121202.0242462', expected '91000121202.0242462', error '0.0000000'

Extra Test:

score: 0
Extra Test Passed