QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#827782#9778. Brotatoucup-team6225WA 62ms5748kbC++14857b2024-12-23 09:56:552024-12-23 09:56:56

Judging History

This is the latest submission verdict.

  • [2024-12-23 09:56:56]
  • Judged
  • Verdict: WA
  • Time: 62ms
  • Memory: 5748kb
  • [2024-12-23 09:56:55]
  • Submitted

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;

const int N = 100010;
int n, k;
double p, f[2][N];
int main() {
    #ifdef Kelly
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    cin >> n >> k >> p;
    if(k >= 170)    {cout << fixed << setprecision(10) << n * p / (1 - p);   return 0;}
    int cur = 0;
    for(int i = 0; i <= k; ++i, cur ^= 1) {
        f[cur][n] = 0;
        for(int j = n - 1; j >= 0; --j) {
            double tmp = pow(double(1) / (1 - p), j + 1) + f[cur][j + 1];
            if(i)   tmp = min(tmp, p * f[cur ^ 1][j] + (1 - p) * f[cur][j + 1] + 1);
            f[cur][j] = tmp;
        }
    }
    cout << fixed << setprecision(10) << f[cur ^ 1][0];
    return 0;
}

详细

Test #1:

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

input:

5 0
0.5

output:

62.0000000000

result:

ok found '62.000000000', expected '62.000000000', error '0.000000000'

Test #2:

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

input:

5 1
0.5

output:

47.0000000000

result:

ok found '47.000000000', expected '47.000000000', error '0.000000000'

Test #3:

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

input:

10000 0
0.002

output:

247489700297.9978942871

result:

ok found '247489700297.997894287', expected '247489700298.253692627', error '0.000000000'

Test #4:

score: 0
Accepted
time: 19ms
memory: 5748kb

input:

100000 10
0.0002

output:

38767507133.0982742310

result:

ok found '38767507133.098274231', expected '38767507133.232215881', error '0.000000000'

Test #5:

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

input:

100000 0
0.0002

output:

2430683127160.1523437500

result:

ok found '2430683127160.152343750', expected '2430683127170.376953125', error '0.000000000'

Test #6:

score: 0
Accepted
time: 32ms
memory: 5720kb

input:

100000 20
0.0002

output:

801073272.2294685841

result:

ok found '801073272.229468584', expected '801073272.231680870', error '0.000000000'

Test #7:

score: 0
Accepted
time: 62ms
memory: 5684kb

input:

100000 40
0.0002

output:

478148.7184258094

result:

ok found '478148.718425809', expected '478148.718426307', error '0.000000000'

Test #8:

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

input:

99995 4
0.0001

output:

38976542.8679226711

result:

ok found '38976542.867922671', expected '38976542.868175834', error '0.000000000'

Test #9:

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

input:

99995 10
0.0001

output:

3549184.5976938535

result:

ok found '3549184.597693854', expected '3549184.597712017', error '0.000000000'

Test #10:

score: 0
Accepted
time: 26ms
memory: 5460kb

input:

99995 16
0.0001

output:

399507.4705554752

result:

ok found '399507.470555475', expected '399507.470556742', error '0.000000000'

Test #11:

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

input:

99990 8
0.0001

output:

7773463.9478873406

result:

ok found '7773463.947887341', expected '7773463.947930722', error '0.000000000'

Test #12:

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

input:

99990 10
0.0001

output:

3547428.9454541830

result:

ok found '3547428.945454183', expected '3547428.945472297', error '0.000000000'

Test #13:

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

input:

99990 12
0.0001

output:

1647102.0204268266

result:

ok found '1647102.020426827', expected '1647102.020434395', error '0.000000000'

Test #14:

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

input:

16664 1
0.0012

output:

257920044630.8178405762

result:

ok found '257920044630.817840576', expected '257920044630.860534668', error '0.000000000'

Test #15:

score: 0
Accepted
time: 6ms
memory: 4452kb

input:

16664 21
0.0012

output:

92190688.5444085002

result:

ok found '92190688.544408500', expected '92190688.544415027', error '0.000000000'

Test #16:

score: 0
Accepted
time: 11ms
memory: 4348kb

input:

16664 41
0.0012

output:

59865.0917859226

result:

ok found '59865.091785923', expected '59865.091785920', error '0.000000000'

Test #17:

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

input:

16659 5
0.0003

output:

63366.2644069268

result:

ok found '63366.264406927', expected '63366.264406955', error '0.000000000'

Test #18:

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

input:

16659 11
0.0003

output:

18120.9118635457

result:

ok found '18120.911863546', expected '18120.911863543', error '0.000000000'

Test #19:

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

input:

16659 17
0.0003

output:

16666.5554519720

result:

ok found '16666.555451972', expected '16666.555451967', error '0.000000000'

Test #20:

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

input:

16654 9
0.0001

output:

16656.0794165772

result:

ok found '16656.079416577', expected '16656.079416576', error '0.000000000'

Test #21:

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

input:

16654 11
0.0001

output:

16655.6741221739

result:

ok found '16655.674122174', expected '16655.674122172', error '0.000000000'

Test #22:

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

input:

16654 13
0.0001

output:

16655.6656953643

result:

ok found '16655.665695364', expected '16655.665695363', error '0.000000000'

Test #23:

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

input:

2774 2
0.0072

output:

28951389306.9896850586

result:

ok found '28951389306.989685059', expected '28951389306.987514496', error '0.000000000'

Test #24:

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

input:

2774 22
0.0072

output:

11312241.4506546035

result:

ok found '11312241.450654604', expected '11312241.450653942', error '0.000000000'

Test #25:

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

input:

2774 42
0.0072

output:

8222.4151085089

result:

ok found '8222.415108509', expected '8222.415108509', error '0.000000000'

Test #26:

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

input:

2769 6
0.0021

output:

13600.5823557331

result:

ok found '13600.582355733', expected '13600.582355732', error '0.000000000'

Test #27:

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

input:

2769 12
0.0021

output:

3239.5499782112

result:

ok found '3239.549978211', expected '3239.549978211', error '0.000000000'

Test #28:

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

input:

2769 18
0.0021

output:

2776.6281948753

result:

ok found '2776.628194875', expected '2776.628194875', error '0.000000000'

Test #29:

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

input:

2764 10
0.0007

output:

2765.9870739550

result:

ok found '2765.987073955', expected '2765.987073955', error '0.000000000'

Test #30:

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

input:

2764 12
0.0007

output:

2765.9373628498

result:

ok found '2765.937362850', expected '2765.937362850', error '0.000000000'

Test #31:

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

input:

2764 14
0.0007

output:

2765.9361767033

result:

ok found '2765.936176703', expected '2765.936176704', error '0.000000000'

Test #32:

score: -100
Wrong Answer
time: 0ms
memory: 3848kb

input:

100000 1000000000
0.0001

output:

10.0010001000

result:

wrong answer 1st numbers differ - expected: '100010.0010001', found: '10.0010001', error = '0.9999000'