QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390984#4687. Weather ReportTWTP_TCTF#AC ✓21ms4184kbC++202.3kb2024-04-16 10:10:472024-04-16 10:10:48

Judging History

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

  • [2024-04-16 10:10:48]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:4184kb
  • [2024-04-16 10:10:47]
  • 提交

answer

#include<iostream>
#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define rep(i, a, b) for(int i = a ; i < b ; i ++)
#define sz(v) (int)v.size()
#define all(v) begin(v), end(v)
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 22;
int ncr[N][N];

void preprocess() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0)ncr[i][j] = 1;
            else {
                ncr[i][j] = ncr[i - 1][j] + ncr[i - 1][j - 1];
            }
        }
    }
}

void doWork() {
    int n;
    cin >> n;
    ld a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ee = 0;
    priority_queue<pair<ld, ll>, vector<pair<ld, ll>>, greater<pair<ld, ll>>> q;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                for (int z = 0; z <= n; z++) {
                    if (i + j + k + z != n)continue;
                    ll cnt = 1ll * ncr[n][i] * ncr[n - i][j] * ncr[n - i - j][k] * ncr[n - i - j - k][z];
                    ee += cnt;
                    ld p = 1;
                    for (int f = 1; f <= i; f++)p *= a;
                    for (int f = 1; f <= j; f++)p *= b;
                    for (int f = 1; f <= k; f++)p *= c;
                    for (int f = 1; f <= z; f++)p *= d;
                    q.push({p, cnt});
                }
            }
        }
    }
    ld ans = 0;
    while (q.size() > 1 || q.top().second > 1) {
        pair<ld, ll> x = q.top();
        q.pop();
        if (x.second == 1) {
            pair<ld, ll> y = q.top();
            q.pop();
            if (y.second - 1 > 0) {
                q.push({y.first, y.second - 1});
            }

            ans += x.first + y.first;
            q.push({x.first + y.first, 1});
            continue;
        }
        ans += x.first * (x.second / 2) * 2;
        q.push({x.first * 2, x.second / 2});
        if (x.second % 2) {
            q.push({x.first, 1});
        }
    }
    cout << fixed << setprecision(9) << ans;
}

int main() {
//    IO
    preprocess();
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3844kb

input:

2
0.9 0.049999 0.05 0.000001

output:

1.457509950

result:

ok found '1.45751', expected '1.45751', error '0.00000'

Test #2:

score: 0
Accepted
time: 14ms
memory: 4052kb

input:

20
0.25 0.25 0.25 0.25

output:

40.000000000

result:

ok found '40.00000', expected '40.00000', error '0.00000'

Test #3:

score: 0
Accepted
time: 14ms
memory: 4064kb

input:

19
0.5 0.3 0.08615 0.11385

output:

32.000055103

result:

ok found '32.00006', expected '32.00006', error '0.00000'

Test #4:

score: 0
Accepted
time: 14ms
memory: 3936kb

input:

19
0.255 0.265 0.235 0.245

output:

37.994344661

result:

ok found '37.99434', expected '37.99435', error '0.00000'

Test #5:

score: 0
Accepted
time: 18ms
memory: 4056kb

input:

20
0.066667 0.133333 0.266667 0.533333

output:

32.848884802

result:

ok found '32.84888', expected '32.84889', error '0.00000'

Test #6:

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

input:

20
0.27 0.26 0.24 0.23

output:

39.970024423

result:

ok found '39.97002', expected '39.97002', error '0.00000'

Test #7:

score: 0
Accepted
time: 21ms
memory: 4176kb

input:

20
0.5 0.2 0.175 0.125

output:

35.617733236

result:

ok found '35.61773', expected '35.61773', error '0.00000'

Test #8:

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

input:

2
0.9 0.05 0.049999 0.000001

output:

1.457509950

result:

ok found '1.45751', expected '1.45751', error '0.00000'

Test #9:

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

input:

3
0.25 0.25 0.25 0.25

output:

6.000000000

result:

ok found '6.00000', expected '6.00000', error '0.00000'

Test #10:

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

input:

9
0.25 0.25 0.25 0.25

output:

18.000000000

result:

ok found '18.00000', expected '18.00000', error '0.00000'

Test #11:

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

input:

9
0.1 0.4 0.3 0.2

output:

16.645985579

result:

ok found '16.64599', expected '16.64599', error '0.00000'

Test #12:

score: 0
Accepted
time: 17ms
memory: 4052kb

input:

20
0.56 0.1 0.01 0.33

output:

27.926967194

result:

ok found '27.92697', expected '27.92697', error '0.00000'

Test #13:

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

input:

1
0.5 0.25 0.125 0.125

output:

1.750000000

result:

ok found '1.75000', expected '1.75000', error '0.00000'

Test #14:

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

input:

2
0.5 0.25 0.125 0.125

output:

3.500000000

result:

ok found '3.50000', expected '3.50000', error '0.00000'

Test #15:

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

input:

3
0.5 0.25 0.125 0.125

output:

5.250000000

result:

ok found '5.25000', expected '5.25000', error '0.00000'

Test #16:

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

input:

11
0.5 0.25 0.125 0.125

output:

19.250000000

result:

ok found '19.25000', expected '19.25000', error '0.00000'

Test #17:

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

input:

1
0.403 0.199 0.199 0.199

output:

1.995000000

result:

ok found '1.99500', expected '1.99500', error '0.00000'

Test #18:

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

input:

1
0.199 0.403 0.199 0.199

output:

1.995000000

result:

ok found '1.99500', expected '1.99500', error '0.00000'

Test #19:

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

input:

1
0.199 0.199 0.403 0.199

output:

1.995000000

result:

ok found '1.99500', expected '1.99500', error '0.00000'

Test #20:

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

input:

1
0.199 0.199 0.199 0.403

output:

1.995000000

result:

ok found '1.99500', expected '1.99500', error '0.00000'

Test #21:

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

input:

4
0.4 0.25 0.24 0.11

output:

7.525134570

result:

ok found '7.52513', expected '7.52513', error '0.00000'

Test #22:

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

input:

4
0.25 0.4 0.24 0.11

output:

7.525134570

result:

ok found '7.52513', expected '7.52513', error '0.00000'

Test #23:

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

input:

4
0.25 0.24 0.4 0.11

output:

7.525134570

result:

ok found '7.52513', expected '7.52513', error '0.00000'

Test #24:

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

input:

4
0.25 0.24 0.11 0.4

output:

7.525134570

result:

ok found '7.52513', expected '7.52513', error '0.00000'

Test #25:

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

input:

4
0.0001 0.0002 0.00034 0.99936

output:

1.008988515

result:

ok found '1.00899', expected '1.00899', error '0.00000'

Test #26:

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

input:

4
0.99936 0.00034 0.0002 0.0001

output:

1.008988515

result:

ok found '1.00899', expected '1.00899', error '0.00000'

Test #27:

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

input:

4
0.00034 0.99936 0.0002 0.0001

output:

1.008988515

result:

ok found '1.00899', expected '1.00899', error '0.00000'

Test #28:

score: 0
Accepted
time: 21ms
memory: 3876kb

input:

20
0.000001 0.999997 0.000001 0.000001

output:

1.000357008

result:

ok found '1.00036', expected '1.00036', error '0.00000'

Test #29:

score: 0
Accepted
time: 7ms
memory: 4004kb

input:

15
0.000001 0.000001 0.999997 0.000001

output:

1.000252004

result:

ok found '1.00025', expected '1.00025', error '0.00000'

Test #30:

score: 0
Accepted
time: 14ms
memory: 3980kb

input:

18
0.01 0.345 0.345 0.3

output:

29.675058743

result:

ok found '29.67506', expected '29.67506', error '0.00000'

Test #31:

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

input:

17
0.13 0.35 0.13 0.39

output:

31.056836159

result:

ok found '31.05684', expected '31.05684', error '0.00000'

Test #32:

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

input:

20
0.14 0.33 0.14 0.39

output:

37.067096889

result:

ok found '37.06710', expected '37.06710', error '0.00000'

Test #33:

score: 0
Accepted
time: 21ms
memory: 4184kb

input:

20
0.125001 0.25 0.5 0.124999

output:

35.000000000

result:

ok found '35.00000', expected '35.00000', error '0.00000'

Test #34:

score: 0
Accepted
time: 21ms
memory: 4056kb

input:

20
0.01 0.34503 0.34503 0.29994

output:

32.967203525

result:

ok found '32.96720', expected '32.96720', error '0.00000'

Test #35:

score: 0
Accepted
time: 21ms
memory: 3936kb

input:

20
0.4 0.2 0.3 0.1

output:

36.959297167

result:

ok found '36.95930', expected '36.95930', error '0.00000'

Test #36:

score: 0
Accepted
time: 20ms
memory: 4068kb

input:

20
0.01 0.02 0.03 0.94

output:

8.324709688

result:

ok found '8.32471', expected '8.32471', error '0.00000'

Test #37:

score: 0
Accepted
time: 20ms
memory: 3992kb

input:

20
0.991 0.003 0.003 0.003

output:

2.121381822

result:

ok found '2.12138', expected '2.12138', error '0.00000'

Test #38:

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

input:

20
0.495 0.005 0.495 0.005

output:

21.675401365

result:

ok found '21.67540', expected '21.67540', error '0.00000'

Test #39:

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

input:

20
0.492 0.008 0.493 0.007

output:

22.322928145

result:

ok found '22.32293', expected '22.32293', error '0.00000'

Test #40:

score: 0
Accepted
time: 17ms
memory: 3992kb

input:

20
0.032 0.051 0.023 0.894

output:

12.985654970

result:

ok found '12.98565', expected '12.98565', error '0.00000'

Test #41:

score: 0
Accepted
time: 17ms
memory: 3872kb

input:

20
0.002 0.01 0.09 0.898

output:

10.761968793

result:

ok found '10.76197', expected '10.76197', error '0.00000'

Test #42:

score: 0
Accepted
time: 21ms
memory: 3992kb

input:

20
0.91 0.03 0.03 0.03

output:

11.642446904

result:

ok found '11.64245', expected '11.64245', error '0.00000'