QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#533218#8795. Mysterious SequencedeepthoughtAC ✓0ms3972kbC++231.1kb2024-08-25 18:46:342024-08-25 18:46:34

Judging History

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

  • [2024-08-25 18:46:34]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3972kb
  • [2024-08-25 18:46:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double a, b, x1, xn;
    int n;
    cin >> a >> b >> n >> x1 >> xn;
    assert(n > 1);
    if(n == 2) {
        cout << x1 << endl << xn << endl;
        return 0;
    }
    double lo = -1e3;
    double hi = 1e6;
    double prec = 1e-9;
    while(hi - lo > prec) {
        double mid = lo + (hi - lo) / 2.0;
        double xs[n + 1];
        xs[1] = x1;
        xs[2] = mid;
        for(int i = 3; i <= n; i++) {
            xs[i] = a * xs[i - 1] + b * xs[i - 2];
        }
        if(abs(xs[n] - xn) / (max(1.0, xn)) < prec) break;
        else if(xs[n] > xn) hi = mid;
        else if(xs[n] < xn) lo = mid;
    }
    double ans[n + 1];
    ans[1] = x1;
    ans[n] = xn;
    ans[2] = lo;
    cout << x1 << endl << fixed << setprecision(9) << lo << endl;
    for(int i = 3; i < n; i++) {
        ans[i] = a * ans[i - 1] + b * ans[i - 2];
        cout << fixed << setprecision(9) << ans[i] << endl;
    }
    cout << xn << endl;
}



这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1
-0.323529414
0.676470586
0.352941173
1.029411759
1.382352931
2.411764690
3.794117622
6.205882312
10.000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1
100

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50
-0.000000056
49.999999944
49.999999888
100.000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1
55.875536296
14.218884074
17.523605093
7.935622292
6.364806846
3.575107284
2.484978533
1.515021454
1.000000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93
-14.204807994
55.038798001
4.810670464
35.877110357
12.000000000

result:

ok 6 numbers

Test #6:

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

input:

0.25 0.80 10 5 63

output:

5
78.769534353
23.692383588
68.938723380
36.188587716
64.198125633
45.000401581
62.608600901
51.652471490
63.000000000

result:

ok 10 numbers

Test #7:

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

input:

0.25 0.99 3 18 30

output:

18
48.719999659
30.000000000

result:

ok 3 numbers

Test #8:

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

input:

0.28 0.64 9 6 10

output:

6
20.950403280
9.706112919
16.125969717
10.727183788
13.324232079
10.596182607
11.494439661
10.000000000

result:

ok 9 numbers

Test #9:

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

input:

0.31 0.40 7 10 49

output:

10
240.115062294
78.435669311
120.361082404
68.686203270
69.437155975
49.000000000

result:

ok 7 numbers

Test #10:

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

input:

0.32 0.28 5 36 6

output:

36
10.121376720
13.318840550
7.096014458
6.000000000

result:

ok 5 numbers

Test #11:

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

input:

0.35 0.65 10 86 82

output:

86
79.533924283
83.736873499
81.004956509
82.780702552
81.626467624
82.376720328
81.889056070
82.206037837
82.000000000

result:

ok 10 numbers

Test #12:

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

input:

0.36 0.68 8 72 59

output:

72
38.239918167
62.726370540
48.584637748
60.144401557
54.689538229
60.586426821
59.000000000

result:

ok 8 numbers

Test #13:

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

input:

0.43 0.61 2 93 84

output:

93
84

result:

ok 2 numbers

Test #14:

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

input:

0.46 0.96 6 65 35

output:

65
-16.617423725
54.755985087
9.235026364
56.813857810
35.000000000

result:

ok 6 numbers

Test #15:

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

input:

0.50 0.90 4 19 1

output:

19
-6.565217394
13.817391303
1.000000000

result:

ok 4 numbers

Test #16:

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

input:

0.54 0.35 3 16 22

output:

16
30.370370182
22.000000000

result:

ok 3 numbers

Test #17:

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

input:

0.55 0.89 10 74 13

output:

74
-48.321937086
39.282934602
-21.400909976
23.191311310
-6.291588658
17.179893304
3.849427411
17.407290117
13.000000000

result:

ok 10 numbers

Test #18:

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

input:

0.56 0.36 3 31 88

output:

31
137.214285517
88.000000000

result:

ok 3 numbers

Test #19:

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

input:

0.57 0.93 7 71 48

output:

71
-34.080565438
46.604077701
-5.130601568
40.417349368
18.266429682
48.000000000

result:

ok 7 numbers

Test #20:

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

input:

0.58 0.41 8 30 69

output:

30
89.432121388
64.170630405
73.886135404
69.163917000
70.408387376
69.194070648
69.000000000

result:

ok 8 numbers

Test #21:

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

input:

0.58 0.49 6 31 96

output:

31
99.557612735
72.933415386
91.084611164
88.566448015
96.000000000

result:

ok 6 numbers

Test #22:

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

input:

0.61 0.29 8 62 25

output:

62
34.407651135
38.968667192
33.749105816
31.887868034
29.238840187
27.083174244
25.000000000

result:

ok 8 numbers

Test #23:

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

input:

0.63 0.89 9 37 85

output:

37
-5.887853360
29.220652383
13.168821511
34.302738172
33.330976193
51.527951975
62.127178556
85.000000000

result:

ok 9 numbers

Test #24:

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

input:

0.64 0.67 2 74 42

output:

74
42

result:

ok 2 numbers

Test #25:

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

input:

0.65 0.56 2 94 96

output:

94
96

result:

ok 2 numbers

Test #26:

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

input:

0.65 0.90 10 97 23

output:

97
-61.703576285
47.192675415
-24.857979637
26.315721109
-5.266962952
20.260623080
8.429138345
23.713500696
23.000000000

result:

ok 10 numbers

Test #27:

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

input:

0.67 0.88 4 70 42

output:

70
0.547821444
61.967040368
42.000000000

result:

ok 4 numbers

Test #28:

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

input:

0.69 0.39 10 2 27

output:

2
22.365907577
16.212476228
19.909312553
20.060291390
21.606232955
22.731814381
24.111382775
25.502261724
27.000000000

result:

ok 10 numbers

Test #29:

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

input:

0.69 0.57 4 88 47

output:

88
11.843609505
58.332090559
47.000000000

result:

ok 4 numbers

Test #30:

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

input:

0.71 0.89 8 4 41

output:

4
6.838890349
8.415612148
12.061697036
16.053699707
22.133037154
30.002249118
41.000000000

result:

ok 8 numbers

Test #31:

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

input:

0.72 0.49 8 21 48

output:

21
19.940442288
24.647118448
27.516742003
31.889142282
36.443386025
41.864917656
48.000000000

result:

ok 8 numbers

Test #32:

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

input:

0.74 0.58 3 57 29

output:

57
-5.486486535
29.000000000

result:

ok 3 numbers

Test #33:

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

input:

0.76 0.70 2 91 18

output:

91
18

result:

ok 2 numbers

Test #34:

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

input:

0.77 0.36 10 31 25

output:

31
5.214972027
15.175528461
13.562546845
15.906351317
17.130407378
18.916700155
20.732805776
22.774272503
25.000000000

result:

ok 10 numbers

Test #35:

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

input:

0.77 0.96 8 78 68

output:

78
-40.097557074
44.004881053
-4.609896380
38.695065599
25.369699986
56.681931964
68.000000000

result:

ok 8 numbers

Test #36:

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

input:

0.78 0.52 7 73 77

output:

73
8.727547440
44.767487003
39.456964531
54.055525576
62.680931505
77.000000000

result:

ok 7 numbers

Test #37:

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

input:

0.78 0.69 4 42 97

output:

42
57.297904927
73.672365843
97.000000000

result:

ok 4 numbers

Test #38:

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

input:

0.78 0.70 10 54 99

output:

54
-13.012886564
27.649948480
12.457939220
29.072156527
31.396839545
44.840044414
56.953022325
75.811388504
99.000000000

result:

ok 10 numbers

Test #39:

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

input:

0.78 0.76 10 97 83

output:

97
-43.734736976
39.606905158
-2.345014078
28.272136939
20.270056113
37.297467842
44.497267563
63.053944259
83.000000000

result:

ok 10 numbers

Test #40:

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

input:

0.78 0.95 10 100 32

output:

100
-63.269578831
45.649728512
-24.499311650
24.257778999
-4.353278448
19.649332859
11.190865104
27.395740998
32.000000000

result:

ok 10 numbers

Test #41:

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

input:

0.79 0.90 10 98 42

output:

98
-58.246914641
42.184937434
-19.096122604
22.880506833
0.889090054
21.294837293
17.623102510
33.087604547
42.000000000

result:

ok 10 numbers

Test #42:

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

input:

0.81 0.48 10 97 1

output:

97
-38.257501683
15.571423636
-5.750747663
2.816177739
-0.479254910
0.963568838
0.550448402
0.908376248
1.000000000

result:

ok 10 numbers

Test #43:

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

input:

0.81 0.86 10 20 100

output:

20
-3.332842903
14.500397249
8.879076875
19.662393903
23.562545174
35.995320347
49.419998331
70.986174147
100.000000000

result:

ok 10 numbers

Test #44:

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

input:

0.84 0.85 10 74 95

output:

74
-36.290804887
32.415723895
-3.617976083
24.514265401
17.516703267
35.551156335
44.752169098
67.810304927
95.000000000

result:

ok 10 numbers

Test #45:

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

input:

0.88 0.37 10 3 96

output:

3
29.021828048
26.649208682
34.189380018
39.946861628
47.803308840
56.847250581
67.712804782
80.620750923
96.000000000

result:

ok 10 numbers

Test #46:

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

input:

0.91 0.50 10 100 98

output:

100
-22.586857894
29.445959316
15.502394031
28.830158226
33.986641001
45.342922424
58.255379906
75.683856927
98.000000000

result:

ok 10 numbers

Test #47:

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

input:

0.94 0.48 10 44 97

output:

44
-1.582743669
19.632220951
17.694570733
26.056362545
32.986374744
43.514246281
56.736851382
74.219478514
97.000000000

result:

ok 10 numbers

Test #48:

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

input:

0.94 0.54 10 28 95

output:

28
0.452546279
15.545393503
14.857044883
22.360134682
29.041330838
39.373323716
52.693242946
70.793243175
95.000000000

result:

ok 10 numbers

Test #49:

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

input:

0.95 0.57 10 2 94

output:

2
9.227284121
9.905919915
14.670175869
19.583041427
26.965889601
36.779928735
50.311489371
68.760474281
94.000000000

result:

ok 10 numbers

Test #50:

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

input:

0.98 0.90 10 21 99

output:

21
-8.213193491
10.851070379
3.242174829
12.943294673
15.602386125
26.939303609
40.442665049
63.879184996
99.000000000

result:

ok 10 numbers

Extra Test:

score: 0
Extra Test Passed