QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#413812#5646. Uniform Chemistrythesupermarketisgoingtome#AC ✓2ms4032kbC++17994b2024-05-18 09:09:592024-05-18 09:10:00

Judging History

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

  • [2024-05-18 09:10:00]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:4032kb
  • [2024-05-18 09:09:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector<int>a(m+1);
	for(int i = 1; i<=m; i++){
		cin >> a[i];
	}
	vector<vector<double>>dp(n+1,vector<double>(n+1));
	vector<vector<double>>psa(n+1,vector<double>(n+1));
	dp[0][n] = 1;
	for(int t = 1; t<=n; t++){
		for(int i = n-1; i>=1; i--){
			double p = ((double)1.0)/(n-i);
			for(int j = i+1; j<=n; j++){
				dp[t][i] += dp[t-1][j]*p;
			}
		}
	}
	for(int t = n-1; t>=1; t--){
		for(int i = 1; i<=n; i++){
			psa[t][i] = dp[t][i];
			psa[t][i]+=psa[t+1][i];
		}
	}
	cout << fixed << setprecision(12);
	for(int i = 1; i<=m; i++){
		double ans = 0;
		for(int t = 1; t<=n; t++){
			double p = dp[t][a[i]];
			for(int j = 1; j<=m; j++){
				if(j==i)continue;
				p*=psa[t][a[j]];
			}
			ans+=p;
		}
		cout << ans;
		if(i<m)cout << ' ';
	}
	cout << '\n';
	return 0;
}

詳細信息

Test #1:

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

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: 3908kb

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: 4012kb

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: 0ms
memory: 4032kb

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: 2ms
memory: 3924kb

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: 2ms
memory: 3992kb

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: 3796kb

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: 4008kb

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: 3816kb

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: 2ms
memory: 3904kb

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: 0ms
memory: 3904kb

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