QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#539784#8795. Mysterious SequenceHTensor#AC ✓0ms3936kbC++171.1kb2024-08-31 15:40:412024-08-31 15:40:41

Judging History

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

  • [2024-08-31 15:40:41]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3936kb
  • [2024-08-31 15:40:41]
  • 提交

answer

#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x  << ": " << x << "\n"
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
const int inf = 0x3f3f3f3f3f3f3f3fLL;

const double eps = 1e-8;

int n; double X1, XN; 
double A, B; 
double f[11];
bool check(double x) {
    f[2] = x;
    for(int i = 3; i <= n; i++) {
        f[i] = A * f[i - 1] + B * f[i - 2];
    }
    return f[n] < XN;
}

void solve() {
    cin >> A >> B;
    cin >> n >> X1 >> XN;
    f[1] = X1;
    double l = -9999999999, r = 9999999999;
    while(fabs(r - l) > eps) {
        double mid = (l + r) / 2;
        if(check(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    check(r);
    for(int i = 1; i <= n; i++) {
        cout << f[i] << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(10);
    int T = 1;
    while(T--) solve();
    return 0;
}


/*

1.0 1.0 10 1 10

*/

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

詳細信息

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.0000000000
-0.3235294064
0.6764705936
0.3529411873
1.0294117809
1.3823529682
2.4117647491
3.7941177173
6.2058824665
10.0000001838

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.0000000000
100.0000000068

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.0000000000
0.0000000000
50.0000000000
50.0000000000
100.0000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.0000000000
55.8755364837
14.2188841209
17.5236051512
7.9356223180
6.3648068673
3.5751072963
2.4849785409
1.5150214593
1.0000000001

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.0000000000
-14.2048079535
55.0387980116
4.8106704922
35.8771103704
12.0000000027

result:

ok 6 numbers

Test #6:

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

input:

0.25 0.80 10 5 63

output:

5.0000000000
78.7695361896
23.6923840474
68.9387249635
36.1885884788
64.1981270905
45.0004025557
62.6086023114
51.6524726224
63.0000000047

result:

ok 10 numbers

Test #7:

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

input:

0.25 0.99 3 18 30

output:

18.0000000000
48.7200000086
30.0000000022

result:

ok 3 numbers

Test #8:

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

input:

0.28 0.64 9 6 10

output:

6.0000000000
20.9504033545
9.7061129393
16.1259697699
10.7271838167
13.3242321214
10.5961826367
11.4944396960
10.0000000023

result:

ok 9 numbers

Test #9:

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

input:

0.31 0.40 7 10 49

output:

10.0000000000
240.1150640058
78.4356698418
120.3610832533
68.6862037452
69.4371564623
49.0000000014

result:

ok 7 numbers

Test #10:

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

input:

0.32 0.28 5 36 6

output:

36.0000000000
10.1213768172
13.3188405815
7.0960144949
6.0000000012

result:

ok 5 numbers

Test #11:

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

input:

0.35 0.65 10 86 82

output:

86.0000000000
79.5339247940
83.7368736779
81.0049569034
82.7807028068
81.6264679696
82.3767206138
81.8890563951
82.2060381372
82.0000000048

result:

ok 10 numbers

Test #12:

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

input:

0.36 0.68 8 72 59

output:

72.0000000000
38.2399186496
62.7263707139
48.5846381388
60.1444018154
54.6895385879
60.5864271261
59.0000000052

result:

ok 8 numbers

Test #13:

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

input:

0.43 0.61 2 93 84

output:

93.0000000000
84.0000000029

result:

ok 2 numbers

Test #14:

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

input:

0.46 0.96 6 65 35

output:

65.0000000000
-16.6174236594
54.7559851167
9.2350264406
56.8138578747
35.0000000054

result:

ok 6 numbers

Test #15:

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

input:

0.50 0.90 4 19 1

output:

19.0000000000
-6.5652173882
13.8173913059
1.0000000036

result:

ok 4 numbers

Test #16:

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

input:

0.54 0.35 3 16 22

output:

16.0000000000
30.3703703735
22.0000000017

result:

ok 3 numbers

Test #17:

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

input:

0.55 0.89 10 74 13

output:

74.0000000000
-48.3219370719
39.2829346105
-21.4009099582
23.1913113263
-6.2915886333
17.1798933321
3.8494274490
17.4072901625
13.0000000189

result:

ok 10 numbers

Test #18:

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

input:

0.56 0.36 3 31 88

output:

31.0000000000
137.2142857185
88.0000000024

result:

ok 3 numbers

Test #19:

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

input:

0.57 0.93 7 71 48

output:

71.0000000000
-34.0805653542
46.6040777481
-5.1306014630
40.4173494718
18.2664298383
48.0000000166

result:

ok 7 numbers

Test #20:

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

input:

0.58 0.41 8 30 69

output:

30.0000000000
89.4321216906
64.1706305805
73.8861356299
69.1639172033
70.4083875862
69.1940708533
69.0000000053

result:

ok 8 numbers

Test #21:

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

input:

0.58 0.49 6 31 96

output:

31.0000000000
99.5576135408
72.9334158537
91.0846118301
88.5664486298
96.0000000020

result:

ok 6 numbers

Test #22:

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

input:

0.61 0.29 8 62 25

output:

62.0000000000
34.4076512647
38.9686672714
33.7491059023
31.8878681091
29.2388402582
27.0831743092
25.0000000035

result:

ok 8 numbers

Test #23:

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

input:

0.63 0.89 9 37 85

output:

37.0000000000
-5.8878532946
29.2206524244
13.1688215952
34.3027382627
33.3309763252
51.5279521386
62.1271787768
85.0000000328

result:

ok 9 numbers

Test #24:

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

input:

0.64 0.67 2 74 42

output:

74.0000000000
42.0000000014

result:

ok 2 numbers

Test #25:

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

input:

0.65 0.56 2 94 96

output:

94.0000000000
96.0000000058

result:

ok 2 numbers

Test #26:

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

input:

0.65 0.90 10 97 23

output:

97.0000000000
-61.7035762787
47.1926754188
-24.8579796286
26.3157211184
-5.2669629388
20.2606230963
8.4291383676
23.7135007256
23.0000000025

result:

ok 10 numbers

Test #27:

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

input:

0.67 0.88 4 70 42

output:

70.0000000000
0.5478215103
61.9670404119
42.0000000051

result:

ok 4 numbers

Test #28:

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

input:

0.69 0.39 10 2 27

output:

2.0000000000
22.3659076914
16.2124763070
19.9093126515
20.0602914893
21.6062330617
22.7318144934
24.1113828945
25.5022618496
27.0000000051

result:

ok 10 numbers

Test #29:

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

input:

0.69 0.57 4 88 47

output:

88.0000000000
11.8436095988
58.3320906232
47.0000000013

result:

ok 4 numbers

Test #30:

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

input:

0.71 0.89 8 4 41

output:

4.0000000000
6.8388903648
8.4156121590
12.0616970575
16.0536997324
22.1330371912
30.0022491676
41.0000000091

result:

ok 8 numbers

Test #31:

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

input:

0.72 0.49 8 21 48

output:

21.0000000000
19.9404423769
24.6471185114
27.5167420929
31.8891423774
36.4433861373
41.8649177838
48.0000000116

result:

ok 8 numbers

Test #32:

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

input:

0.74 0.58 3 57 29

output:

57.0000000000
-5.4864864816
29.0000000036

result:

ok 3 numbers

Test #33:

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

input:

0.76 0.70 2 91 18

output:

91.0000000000
18.0000000043

result:

ok 2 numbers

Test #34:

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

input:

0.77 0.36 10 31 25

output:

31.0000000000
5.2149720908
15.1755285099
13.5625469053
15.9063513807
17.1304074490
18.9167002328
20.7328058609
22.7742725967
25.0000000094

result:

ok 10 numbers

Test #35:

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

input:

0.77 0.96 8 78 68

output:

78.0000000000
-40.0975570068
44.0048811047
-4.6098962759
38.6950657281
25.3697001858
56.6819322420
68.0000000047

result:

ok 8 numbers

Test #36:

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

input:

0.78 0.52 7 73 77

output:

73.0000000000
8.7275475119
44.7674870593
39.4569646125
54.0555256686
62.6809316200
77.0000000112

result:

ok 7 numbers

Test #37:

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

input:

0.78 0.69 4 42 97

output:

42.0000000000
57.2979051214
73.6723659947
97.0000000096

result:

ok 4 numbers

Test #38:

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

input:

0.78 0.70 10 54 99

output:

54.0000000000
-13.0128863488
27.6499486480
12.4579395013
29.0721568646
31.3968400053
44.8400450093
56.9530231109
75.8113895330
99.0000000134

result:

ok 10 numbers

Test #39:

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

input:

0.78 0.76 10 97 83

output:

97.0000000000
-43.7347369561
39.6069051743
-2.3450140507
28.2721369729
20.2700561604
37.2974679045
44.4972676474
63.0539443724
83.0000000225

result:

ok 10 numbers

Test #40:

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

input:

0.78 0.95 10 100 32

output:

100.0000000000
-63.2695788145
45.6497285247
-24.4993116246
24.2577790312
-4.3532783990
19.6493329285
11.1908652052
27.3957411421
32.0000000357

result:

ok 10 numbers

Test #41:

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

input:

0.79 0.90 10 98 42

output:

98.0000000000
-58.2469146208
42.1849374496
-19.0961225735
22.8805068716
0.8890901124
21.2948373732
17.6231026259
33.0876047103
42.0000000845

result:

ok 10 numbers

Test #42:

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

input:

0.81 0.48 10 97 1

output:

97.0000000000
-38.2575016767
15.5714236419
-5.7507476549
2.8161777476
-0.4792548988
0.9635688509
0.5504484178
0.9083762668
1.0000000167

result:

ok 10 numbers

Test #43:

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

input:

0.81 0.86 10 20 100

output:

20.0000000000
-3.3328428642
14.5003972800
8.8790769336
19.6623939770
23.5625452842
35.9953205005
49.4199985498
70.9861744557
100.0000000620

result:

ok 10 numbers

Test #44:

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

input:

0.84 0.85 10 74 95

output:

74.0000000000
-36.2908048715
32.4157239080
-3.6179760581
24.5142654330
17.5167033144
35.5511564021
44.7521691950
67.8103050655
95.0000000708

result:

ok 10 numbers

Test #45:

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

input:

0.88 0.37 10 3 96

output:

3.0000000000
29.0218284965
26.6492090769
34.1893805314
39.9468622261
47.8033095556
56.8472514326
67.7128057963
80.6207521308
96.0000000197

result:

ok 10 numbers

Test #46:

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

input:

0.91 0.50 10 100 98

output:

100.0000000000
-22.5868578505
29.4459593560
15.5023940887
28.8301582987
33.9866410962
45.3429225469
58.2553800657
75.6838571332
98.0000000241

result:

ok 10 numbers

Test #47:

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

input:

0.94 0.48 10 44 97

output:

44.0000000000
-1.5827434327
19.6322211733
17.6945710552
26.0563629551
32.9863752842
43.5142469856
56.7368523029
74.2194797178
97.0000000402

result:

ok 10 numbers

Test #48:

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

input:

0.94 0.54 10 28 95

output:

28.0000000000
0.4525463077
15.5453935292
14.8570449236
22.3601347340
29.0413309087
39.3733238105
52.6932430725
70.7932433459
95.0000000043

result:

ok 10 numbers

Test #49:

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

input:

0.95 0.57 10 2 94

output:

2.0000000000
9.2272841789
9.9059199699
14.6701759534
19.5830415386
26.9658897551
36.7799289443
50.3114896575
68.7604746729
94.0000000440

result:

ok 10 numbers

Test #50:

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

input:

0.98 0.90 10 21 99

output:

21.0000000000
-8.2131934839
10.8510703858
3.2421748426
12.9432946930
15.6023861575
26.9393036580
40.4426651265
63.8791851162
99.0000000278

result:

ok 10 numbers

Extra Test:

score: 0
Extra Test Passed