QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559195#5646. Uniform Chemistryship2077AC ✓1ms4028kbC++23645b2024-09-11 20:43:592024-09-11 20:44:01

Judging History

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

  • [2024-09-11 20:44:01]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4028kb
  • [2024-09-11 20:43:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=105;
int n,m,a[M];
double dp[M][M];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) scanf("%d",&a[i]);
	dp[0][n]=1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<n;j++){
			double inv=1./(n-j);
			for (int k=j+1;k<=n;k++)
				dp[i][j]+=dp[i-1][k]*inv;
		}
	for (int i=1;i<=m;i++){
		double ans=0;
		for (int j=1;j<=n;j++){
			double coef=dp[j][a[i]];
			for (int k=1;k<=m;k++){
				if (i==k) continue;
				double tmp=0;
				for (int p=j;p<=n;p++)
					tmp+=dp[p][a[k]];
				coef*=tmp;
			}
			ans+=coef;
		}
		printf("%.12lf ",ans);
	}
	return 0;
}

详细

Test #1:

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

input:

2 3
1 1 1

output:

1.000000000000 1.000000000000 1.000000000000 

result:

ok 3 numbers, max absolute error 0

Test #2:

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

input:

3 3
1 1 2

output:

0.500000000000 0.500000000000 1.000000000000 

result:

ok 3 numbers, max absolute error 0

Test #3:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

3 3
1 1 1

output:

0.625000000000 0.625000000000 0.625000000000 

result:

ok 3 numbers, max absolute error 0

Test #4:

score: 0
Accepted
time: 1ms
memory: 4028kb

input:

100 7
1 2 4 8 16 32 64

output:

0.178593468624 0.179810454731 0.182306770639 0.187565365588 0.199300429529 0.229356322414 0.348722517944 

result:

ok 7 numbers, max absolute error 4.70999989e-10

Test #5:

score: 0
Accepted
time: 1ms
memory: 4000kb

input:

100 10
28 58 38 53 1 19 66 60 68 31

output:

0.132031244734 0.195478375445 0.147278326003 0.180169450530 0.104495283362 0.121112032972 0.227744175567 0.202506824313 0.237924893251 0.136207268849 

result:

ok 10 numbers, max absolute error 4.36900516e-13

Test #6:

score: 0
Accepted
time: 1ms
memory: 4000kb

input:

100 10
86 50 88 42 88 20 29 83 89 34

output:

0.263353545116 0.096016845558 0.297346284686 0.085266761167 0.297346284686 0.065861647587 0.072497069566 0.225981038841 0.318427805743 0.076875608528 

result:

ok 10 numbers, max absolute error 3.3945069e-13

Test #7:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

2 1
1

output:

1.000000000000 

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

10 3
4 6 7

output:

0.372135416667 0.523495370370 0.667843364198 

result:

ok 3 numbers, max absolute error 4.6918025e-13

Test #9:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

20 10
6 6 9 3 14 15 13 8 6 11

output:

0.151917737209 0.151917737209 0.187146469189 0.128427543102 0.316234203356 0.370434570308 0.276697753353 0.173582076306 0.151917737209 0.222613362677 

result:

ok 10 numbers, max absolute error 4.08451051e-13

Test #10:

score: 0
Accepted
time: 1ms
memory: 4000kb

input:

99 2
40 55

output:

0.536614024946 0.629592693813 

result:

ok 2 numbers, max absolute error 4.27435864e-13

Test #11:

score: 0
Accepted
time: 1ms
memory: 3964kb

input:

99 9
86 68 85 83 75 70 71 73 70

output:

0.294574117090 0.149234490230 0.278029476178 0.250514065747 0.182435429935 0.157263875388 0.161657850037 0.171338171587 0.157263875388 

result:

ok 9 numbers, max absolute error 4.66238159e-13