QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#83937#5646. Uniform Chemistryzrzluck99#AC ✓3ms3932kbC++141.6kb2023-03-04 15:07:152023-03-04 15:07:17

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

ll read(){
	ll s=0,w=1; char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') w=-1; ch=getchar();}
	while (ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^'0'), ch=getchar();
	return s*w;
}

void write(ll s){
	if (s<0) s=-s,putchar('-');
	if (s>9) write(s/10);
	putchar(s%10+'0');
}

void writeln(ll s){
	write(s); puts("");
}

void writeln(){
	puts("");
}

double f[105][105],s[105][105];

int n,m;
int a[107];

signed main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++) scanf("%d",&a[i]);
    f[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++){
                f[i][j] += f[k][j-1]/(n-i);
            }
        }
    }
    for (int i=n-1;i>=1;i--){
        s[i][0] = 1.0;
        for (int j=1;j<=n;j++){
            s[i][j] = s[i][j-1] - f[i][j];
        }
    }
    for (int i=1;i<=m;i++){
        double ans = 0.0;
        for (int j=1;j<=n;j++){
            double p = f[a[i]][j];
            for (int k=1;k<=m;k++){
                if (i==k) continue;
                p *= s[a[k]][j-1];
            }
            //printf("%.9lf ",p);
            ans += p;
        }
        printf("%.9lf ",ans);
    }
    puts("");
    /*
    for (int i=1;i<=n;i++){
        for (int j=0;j<=n;j++){
            printf("%.2lf ",f[i][j]);
        }
        puts("");
    }
    puts("");
    for (int i=1;i<=n;i++){
        for (int j=0;j<=n;j++){
            printf("%.2lf ",s[i][j]);
        }
        puts("");
    }
    */
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3768kb

input:

2 3
1 1 1

output:

1.000000000 1.000000000 1.000000000 

result:

ok 3 numbers, max absolute error 0

Test #2:

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

input:

3 3
1 1 2

output:

0.500000000 0.500000000 1.000000000 

result:

ok 3 numbers, max absolute error 0

Test #3:

score: 0
Accepted
time: 2ms
memory: 3628kb

input:

3 3
1 1 1

output:

0.625000000 0.625000000 0.625000000 

result:

ok 3 numbers, max absolute error 0

Test #4:

score: 0
Accepted
time: 2ms
memory: 3832kb

input:

100 7
1 2 4 8 16 32 64

output:

0.178593469 0.179810455 0.182306771 0.187565366 0.199300430 0.229356322 0.348722518 

result:

ok 7 numbers, max absolute error 0

Test #5:

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

input:

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

output:

0.132031245 0.195478375 0.147278326 0.180169451 0.104495283 0.121112033 0.227744176 0.202506824 0.237924893 0.136207269 

result:

ok 10 numbers, max absolute error 4.7022003e-10

Test #6:

score: 0
Accepted
time: 2ms
memory: 3724kb

input:

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

output:

0.263353545 0.096016846 0.297346285 0.085266761 0.297346285 0.065861648 0.072497070 0.225981039 0.318427806 0.076875609 

result:

ok 10 numbers, max absolute error 4.71872028e-10

Test #7:

score: 0
Accepted
time: 2ms
memory: 3616kb

input:

2 1
1

output:

1.000000000 

result:

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

Test #8:

score: 0
Accepted
time: 2ms
memory: 3548kb

input:

10 3
4 6 7

output:

0.372135417 0.523495370 0.667843364 

result:

ok 3 numbers, max absolute error 3.70370512e-10

Test #9:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

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

output:

0.151917737 0.151917737 0.187146469 0.128427543 0.316234203 0.370434570 0.276697753 0.173582076 0.151917737 0.222613363 

result:

ok 10 numbers, max absolute error 3.55591556e-10

Test #10:

score: 0
Accepted
time: 2ms
memory: 3740kb

input:

99 2
40 55

output:

0.536614025 0.629592694 

result:

ok 2 numbers, max absolute error 1.87258653e-10

Test #11:

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

input:

99 9
86 68 85 83 75 70 71 73 70

output:

0.294574117 0.149234490 0.278029476 0.250514066 0.182435430 0.157263875 0.161657850 0.171338172 0.157263875 

result:

ok 9 numbers, max absolute error 4.1291634e-10