QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#24307#3466. Dice Bettingregis2AC ✓13ms72068kbC++14689b2022-03-29 14:11:462022-04-30 05:24:27

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 05:24:27]
  • 评测
  • 测评结果:AC
  • 用时:13ms
  • 内存:72068kb
  • [2022-03-29 14:11:46]
  • 提交

answer

#include <iostream>
#include <numeric>
#include <cstdio>
using namespace std;

#define rep(i,a,b) for(__typeof(b) i=a; i<(b); ++i)

typedef long long ll;
double pr[10001][1001];
int main()
{
    int n, s, k;

    while (scanf("%d %d %d", &n, &s, &k) == 3)
    {
        rep(i,0,n+1) rep(j,0,k+1)
            pr[i][j] = 0;

        pr[0][0] = 1;
        rep(i,0,n) rep(j,0,k)
            if (pr[i][j] > 0)
        {
            double p = double(j) / s;
            pr[i + 1][j + 1] += pr[i][j] * (1 - p);
            pr[i + 1][j] += pr[i][j] * p;
        }

        double res = accumulate(pr[n], pr[n] + k, 0.0);
        printf("%.9lf\n", 1 - res);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3 2

output:

0.888888889

result:

ok found '0.8888889', expected '0.8888889', error '0.0000000'

Test #2:

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

input:

3 3 3

output:

0.222222222

result:

ok found '0.2222222', expected '0.2222222', error '0.0000000'

Test #3:

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

input:

6 3 1

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #4:

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

input:

10 1 1

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #5:

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

input:

26 3 2

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #6:

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

input:

57 2 2

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #7:

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

input:

92 38 34

output:

0.797551122

result:

ok found '0.7975511', expected '0.7975511', error '0.0000000'

Test #8:

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

input:

62 28 13

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #9:

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

input:

1989 488 343

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #10:

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

input:

5851 242 124

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #11:

score: 0
Accepted
time: 4ms
memory: 60076kb

input:

9676 187 138

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #12:

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

input:

5621 188 110

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #13:

score: 0
Accepted
time: 5ms
memory: 25600kb

input:

2893 207 131

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #14:

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

input:

5103 91 2

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #15:

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

input:

5079 64 37

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #16:

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

input:

3360 185 136

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #17:

score: 0
Accepted
time: 8ms
memory: 60916kb

input:

10000 500 126

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #18:

score: 0
Accepted
time: 13ms
memory: 72068kb

input:

10000 500 317

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'