QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#630043#8795. Mysterious Sequenceqianchen06#AC ✓1ms4044kbC++141.3kb2024-10-11 16:09:052024-10-11 16:09:05

Judging History

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

  • [2024-10-11 16:09:05]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4044kb
  • [2024-10-11 16:09:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const double eps = 1e-7;
void solve()
{
    double a, b;
    int n;
    cin >> a >> b >> n;
    vector<double> x(n + 1);
    cin >> x[1] >> x[n];
    if (n == 2)
    {
        cout << fixed << setprecision(10);
        cout << x[1] << '\n';
        cout << x[n] << '\n';
        return;
    }
    auto check = [&](double y)
    {
        x[2] = y;

        for (int i = 3; i < n; i++)
        {
            x[i] = x[i - 1] * a + x[i - 2] * b;
        }
        double res = x[n - 1] * a + x[n - 2] * b;
        return res >= x[n];
    };
    double l = -1e9,
           r = 1e9;
    cout << fixed << setprecision(10);
    while (l <= r)
    {
        if (r - l < eps)
        {
            break;
        }
        double mid = (l + r) / 2.0;
        if (check(mid))
        {
            r = mid;
        }
        else
            l = mid;
    }
    x[2] = l;

    for (int i = 3; i < n; i++)
    {
        x[i] = x[i - 1] * a + x[i - 2] * b;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << x[i] << '\n';
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.0000000000
-0.3235294255
0.6764705745
0.3529411491
1.0294117236
1.3823528726
2.4117645962
3.7941174689
6.2058820651
10.0000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.0000000000
100.0000000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.0000000000
-0.0000000555
49.9999999445
49.9999998890
100.0000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.0000000000
55.8755364755
14.2188841189
17.5236051486
7.9356223169
6.3648068664
3.5751072958
2.4849785405
1.5150214591
1.0000000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.0000000000
-14.2048079965
55.0387980009
4.8106704624
35.8771103562
12.0000000000

result:

ok 6 numbers

Test #6:

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

input:

0.25 0.80 10 5 63

output:

5.0000000000
78.7695361715
23.6923840429
68.9387249479
36.1885884713
64.1981270761
45.0004025460
62.6086022974
51.6524726112
63.0000000000

result:

ok 10 numbers

Test #7:

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

input:

0.25 0.99 3 18 30

output:

18.0000000000
48.7199999788
30.0000000000

result:

ok 3 numbers

Test #8:

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

input:

0.28 0.64 9 6 10

output:

6.0000000000
20.9504033011
9.7061129243
16.1259697315
10.7271837964
13.3242320911
10.5961826152
11.4944396706
10.0000000000

result:

ok 9 numbers

Test #9:

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

input:

0.31 0.40 7 10 49

output:

10.0000000000
240.1150639986
78.4356698396
120.3610832497
68.6862037432
69.4371564603
49.0000000000

result:

ok 7 numbers

Test #10:

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

input:

0.32 0.28 5 36 6

output:

36.0000000000
10.1213767922
13.3188405735
7.0960144854
6.0000000000

result:

ok 5 numbers

Test #11:

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

input:

0.35 0.65 10 86 82

output:

86.0000000000
79.5339247794
83.7368736728
81.0049568921
82.7807027996
81.6264679597
82.3767206056
81.8890563858
82.2060381287
82.0000000000

result:

ok 10 numbers

Test #12:

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

input:

0.36 0.68 8 72 59

output:

72.0000000000
38.2399186205
62.7263707034
48.5846381152
60.1444017998
54.6895385662
60.5864271077
59.0000000000

result:

ok 8 numbers

Test #13:

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

input:

0.43 0.61 2 93 84

output:

93.0000000000
84.0000000000

result:

ok 2 numbers

Test #14:

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

input:

0.46 0.96 6 65 35

output:

65.0000000000
-16.6174237148
54.7559850912
9.2350263757
56.8138578203
35.0000000000

result:

ok 6 numbers

Test #15:

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

input:

0.50 0.90 4 19 1

output:

19.0000000000
-6.5652174253
13.8173912874
1.0000000000

result:

ok 4 numbers

Test #16:

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

input:

0.54 0.35 3 16 22

output:

16.0000000000
30.3703703297
22.0000000000

result:

ok 3 numbers

Test #17:

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

input:

0.55 0.89 10 74 13

output:

74.0000000000
-48.3219371183
39.2829345849
-21.4009100136
23.1913112731
-6.2915887119
17.1798932415
3.8494273292
17.4072900160
13.0000000000

result:

ok 10 numbers

Test #18:

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

input:

0.56 0.36 3 31 88

output:

31.0000000000
137.2142857115
88.0000000000

result:

ok 3 numbers

Test #19:

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

input:

0.57 0.93 7 71 48

output:

71.0000000000
-34.0805653698
46.6040777392
-5.1306014826
40.4173494524
18.2664298091
48.0000000000

result:

ok 7 numbers

Test #20:

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

input:

0.58 0.41 8 30 69

output:

30.0000000000
89.4321216527
64.1706305586
73.8861356016
69.1639171779
70.4083875598
69.1940708277
69.0000000000

result:

ok 8 numbers

Test #21:

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

input:

0.58 0.49 6 31 96

output:

31.0000000000
99.5576134866
72.9334158222
91.0846117853
88.5664485884
96.0000000000

result:

ok 6 numbers

Test #22:

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

input:

0.61 0.29 8 62 25

output:

62.0000000000
34.4076512282
38.9686672492
33.7491058782
31.8878680880
29.2388402383
27.0831742909
25.0000000000

result:

ok 8 numbers

Test #23:

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

input:

0.63 0.89 9 37 85

output:

37.0000000000
-5.8878533160
29.2206524109
13.1688215676
34.3027382333
33.3309762822
51.5279520854
62.1271787050
85.0000000000

result:

ok 9 numbers

Test #24:

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

input:

0.64 0.67 2 74 42

output:

74.0000000000
42.0000000000

result:

ok 2 numbers

Test #25:

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

input:

0.65 0.56 2 94 96

output:

94.0000000000
96.0000000000

result:

ok 2 numbers

Test #26:

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

input:

0.65 0.90 10 97 23

output:

97.0000000000
-61.7035763040
47.1926754024
-24.8579796620
26.3157210819
-5.2669629926
20.2606230285
8.4291382752
23.7135006045
23.0000000000

result:

ok 10 numbers

Test #27:

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

input:

0.67 0.88 4 70 42

output:

70.0000000000
0.5478214549
61.9670403748
42.0000000000

result:

ok 4 numbers

Test #28:

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

input:

0.69 0.39 10 2 27

output:

2.0000000000
22.3659076815
16.2124763002
19.9093126429
20.0602914807
21.6062330524
22.7318144836
24.1113828841
25.5022618387
27.0000000000

result:

ok 10 numbers

Test #29:

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

input:

0.69 0.57 4 88 47

output:

88.0000000000
11.8436095931
58.3320906192
47.0000000000

result:

ok 4 numbers

Test #30:

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

input:

0.71 0.89 8 4 41

output:

4.0000000000
6.8388903429
8.4156121435
12.0616970271
16.0536996969
22.1330371389
30.0022490989
41.0000000000

result:

ok 8 numbers

Test #31:

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

input:

0.72 0.49 8 21 48

output:

21.0000000000
19.9404423529
24.6471184941
27.5167420686
31.8891423515
36.4433861067
41.8649177491
48.0000000000

result:

ok 8 numbers

Test #32:

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

input:

0.74 0.58 3 57 29

output:

57.0000000000
-5.4864864873
29.0000000000

result:

ok 3 numbers

Test #33:

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

input:

0.76 0.70 2 91 18

output:

91.0000000000
18.0000000000

result:

ok 2 numbers

Test #34:

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

input:

0.77 0.36 10 31 25

output:

31.0000000000
5.2149720653
15.1755284903
13.5625468810
15.9063513549
17.1304074204
18.9167002015
20.7328058265
22.7742725589
25.0000000000

result:

ok 10 numbers

Test #35:

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

input:

0.77 0.96 8 78 68

output:

78.0000000000
-40.0975570525
44.0048810696
-4.6098963468
38.6950656398
25.3697000497
56.6819320525
68.0000000000

result:

ok 8 numbers

Test #36:

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

input:

0.78 0.52 7 73 77

output:

73.0000000000
8.7275474625
44.7674870208
39.4569645567
54.0555256050
62.6809315414
77.0000000000

result:

ok 7 numbers

Test #37:

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

input:

0.78 0.69 4 42 97

output:

42.0000000000
57.2979050872
73.6723659680
97.0000000000

result:

ok 4 numbers

Test #38:

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

input:

0.78 0.70 10 54 99

output:

54.0000000000
-13.0128863796
27.6499486239
12.4579394610
29.0721568163
31.3968399394
44.8400449242
56.9530229985
75.8113893857
99.0000000000

result:

ok 10 numbers

Test #39:

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

input:

0.78 0.76 10 97 83

output:

97.0000000000
-43.7347369986
39.6069051411
-2.3450141089
28.2721369023
20.2700560611
37.2974677734
44.4972674697
63.0539441341
83.0000000000

result:

ok 10 numbers

Test #40:

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

input:

0.78 0.95 10 100 32

output:

100.0000000000
-63.2695788538
45.6497284940
-24.4993116858
24.2577789544
-4.3532785171
19.6493327633
11.1908649641
27.3957407972
32.0000000000

result:

ok 10 numbers

Test #41:

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

input:

0.79 0.90 10 98 42

output:

98.0000000000
-58.2469146804
42.1849374025
-19.0961226644
22.8805067574
0.8890899404
21.2948371346
17.6231022828
33.0876042245
42.0000000000

result:

ok 10 numbers

Test #42:

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

input:

0.81 0.48 10 97 1

output:

97.0000000000
-38.2575017221
15.5714236051
-5.7507477065
2.8161776881
-0.4792549717
0.9635687632
0.5504483117
0.9083761388
1.0000000000

result:

ok 10 numbers

Test #43:

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

input:

0.81 0.86 10 20 100

output:

20.0000000000
-3.3328428906
14.5003972586
8.8790768936
19.6623939263
23.5625452088
35.9953203957
49.4199984001
70.9861742444
100.0000000000

result:

ok 10 numbers

Test #44:

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

input:

0.84 0.85 10 74 95

output:

74.0000000000
-36.2908049167
32.4157238699
-3.6179761285
24.5142653415
17.5167031777
35.5511562095
44.7521689170
67.8103046684
95.0000000000

result:

ok 10 numbers

Test #45:

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

input:

0.88 0.37 10 3 96

output:

3.0000000000
29.0218284404
26.6492090276
34.1893804672
39.9468621514
47.8033094661
56.8472513262
67.7128056695
80.6207519798
96.0000000000

result:

ok 10 numbers

Test #46:

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

input:

0.91 0.50 10 100 98

output:

100.0000000000
-22.5868578840
29.4459593255
15.5023940442
28.8301582430
33.9866410232
45.3429224526
58.2553799435
75.6838569749
98.0000000000

result:

ok 10 numbers

Test #47:

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

input:

0.94 0.48 10 44 97

output:

44.0000000000
-1.5827434918
19.6322211177
17.6945709745
26.0563628526
32.9863751492
43.5142468095
56.7368520725
74.2194794167
97.0000000000

result:

ok 10 numbers

Test #48:

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

input:

0.94 0.54 10 28 95

output:

28.0000000000
0.4525462782
15.5453935015
14.8570448817
22.3601346796
29.0413308349
39.3733237118
52.6932429400
70.7932431680
95.0000000000

result:

ok 10 numbers

Test #49:

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

input:

0.95 0.57 10 2 94

output:

2.0000000000
9.2272841590
9.9059199510
14.6701759241
19.5830415000
26.9658897017
36.7799288716
50.3114895580
68.7604745369
94.0000000000

result:

ok 10 numbers

Test #50:

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

input:

0.98 0.90 10 21 99

output:

21.0000000000
-8.2131935142
10.8510703561
3.2421747862
12.9432946110
15.6023860263
26.9393034557
40.4426648103
63.8791846242
99.0000000000

result:

ok 10 numbers

Extra Test:

score: 0
Extra Test Passed