QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#124804#5646. Uniform ChemistryHongzy#AC ✓3ms4060kbC++141.3kb2023-07-15 15:51:382023-07-15 15:51:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 15:51:39]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:4060kb
  • [2023-07-15 15:51:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int gi() {
	int res = 0, w = 1;
	char ch = getchar();
	while (ch != '-' && !isdigit(ch)) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
	return res * w;
}
#define fi first
#define se second
#define pii pair<int, int>
using LL = long long;
using db = long double;
const int Mod = 998244353;
const int MAX_N = 105;
int N, M, a[MAX_N];
char str[MAX_N];
db C[MAX_N][MAX_N], suf[MAX_N][MAX_N];
db f(int s, int i) { return C[s][i]; }
void solve() {
	N = gi(), M = gi();
	for (int i = 1; i <= M; i++) a[i] = gi();
	C[N][0] = 1.0;
    for (int i = N - 1; i >= 1; i--)
        for (int j = 1; j <= N; j++)
            for (int k = i + 1; k <= N; k++)
                C[i][j] += C[k][j - 1] / (N - i);
	for (int i = 1; i < N; i++)
		for (int j = N - i; j >= 1; j--)
			suf[i][j] = suf[i][j + 1] + f(i, j);
	for (int i = 1; i <= M; i++) {
		db ans = 0;
		for (int j = 1; j <= N - a[i]; j++) {
			db tms = f(a[i], j);
			for (int k = 1; k <= M; k++)
				if (k != i) tms *= suf[a[k]][j];
			ans += tms;
		}
		printf("%0.10Lf ", ans);
	}
}
int main () {
#ifndef ONLINE_JUDGE
    freopen("cpp.in", "r", stdin);
	//freopen("cpp.out", "w", stdout);
#endif
	int T = 1; //T = gi();
	while (T--) {
		solve();
	}
    return 0;
}

详细

Test #1:

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

input:

2 3
1 1 1

output:

1.0000000000 1.0000000000 1.0000000000 

result:

ok 3 numbers, max absolute error 0

Test #2:

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

input:

3 3
1 1 2

output:

0.5000000000 0.5000000000 1.0000000000 

result:

ok 3 numbers, max absolute error 0

Test #3:

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

input:

3 3
1 1 1

output:

0.6250000000 0.6250000000 0.6250000000 

result:

ok 3 numbers, max absolute error 0

Test #4:

score: 0
Accepted
time: 3ms
memory: 3932kb

input:

100 7
1 2 4 8 16 32 64

output:

0.1785934686 0.1798104547 0.1823067706 0.1875653656 0.1993004295 0.2293563224 0.3487225179 

result:

ok 7 numbers, max absolute error 5.00000014e-10

Test #5:

score: 0
Accepted
time: 3ms
memory: 3920kb

input:

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

output:

0.1320312447 0.1954783754 0.1472783260 0.1801694505 0.1044952834 0.1211120330 0.2277441756 0.2025068243 0.2379248933 0.1362072688 

result:

ok 10 numbers, max absolute error 4.86312102e-11

Test #6:

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

input:

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

output:

0.2633535451 0.0960168456 0.2973462847 0.0852667612 0.2973462847 0.0658616476 0.0724970696 0.2259810388 0.3184278057 0.0768756085 

result:

ok 10 numbers, max absolute error 4.29709601e-11

Test #7:

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

input:

2 1
1

output:

1.0000000000 

result:

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

Test #8:

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

input:

10 3
4 6 7

output:

0.3721354167 0.5234953704 0.6678433642 

result:

ok 3 numbers, max absolute error 3.33333916e-11

Test #9:

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

input:

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

output:

0.1519177372 0.1519177372 0.1871464692 0.1284275431 0.3162342034 0.3704345703 0.2766977534 0.1735820763 0.1519177372 0.2226133627 

result:

ok 10 numbers, max absolute error 4.67095806e-11

Test #10:

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

input:

99 2
40 55

output:

0.5366140249 0.6295926938 

result:

ok 2 numbers, max absolute error 4.64274175e-11

Test #11:

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

input:

99 9
86 68 85 83 75 70 71 73 70

output:

0.2945741171 0.1492344902 0.2780294762 0.2505140657 0.1824354299 0.1572638754 0.1616578500 0.1713381716 0.1572638754 

result:

ok 9 numbers, max absolute error 4.65337768e-11