QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#497557#8795. Mysterious SequenceemtAC ✓0ms4140kbC++142.4kb2024-07-29 13:38:582024-07-29 13:39:03

Judging History

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

  • [2024-07-29 13:39:03]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:4140kb
  • [2024-07-29 13:38:58]
  • 提交

answer

// #pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using ld = long double;
using u64 = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
#define mem(a, b) memset((a), (b), sizeof(a))
#define all(a) (a).begin(), (a).end()
#define inf 0x3f3f3f3f
#define lowbit(x) (-x) & x
#define ls u << 1
#define rs u << 1 | 1
#define int long long
mt19937 rnd(time(0));
const int MOD = 1e9+7;
int qmi(int m, int k){int res = 1, t = m;while (k){if (k & 1) res = (res * t) % MOD;t = t * t % MOD;k >>= 1;}return res;}
const int N = 1e6 + 7;
const ld eps = 1;
vector<array<int,6>> cor;
void solve()
{
    int n;
    ld a,b,x1,xn;
    cin>>a>>b>>n;
    vector<ld> x(n+1);
    cin>>x[1]>>x[n];
    map<array<int,2>,int> ma[n+1][3];
    ma[1][1][{0,0}] = 1;
    ma[2][2][{0,0}] = 1;
    // ma[3][1][{0,1}] = 1;
    // ma[3][2][{1,0}] = 1;
    for(int i=3;i<=n;i++)
    {
        for(int j=1;j<=2;j++)
        {
            for(auto [c,d]:ma[i-2][j])
            {
                auto [a,b] = c;
                ma[i][j][{a,b+1}]+=d;
            }
            for(auto [c,d]:ma[i-1][j])
            {
                auto [a,b] = c;
                ma[i][j][{a+1,b}]+=d;
            }
        }
        // cout<<i<<"\n";
        // for(auto [c,d]:ma[i][1])
        //     cout<<d<<"* "<<"<"<<c[0]<<" "<<c[1]<<">, ";
        // cout<<"\n";
        // for(auto [c,d]:ma[i][2])
        //     cout<<d<<"* "<<"<"<<c[0]<<" "<<c[1]<<">, ";
        // cout<<"\n";
    }
    ld k1 = 0, k2 = 0;
    for(auto [c,d]:ma[n][1])
    {
        auto [a0,b0] = c;
        ld res = d;
        for(int i=1;i<=a0;i++)
            res *= a;
        for(int i=1;i<=b0;i++)
            res *= b;
        k1 += res;
    }
    for(auto [c,d]:ma[n][2])
    {
        auto [a0,b0] = c;
        ld res = d;
        for(int i=1;i<=a0;i++)
            res *= a;
        for(int i=1;i<=b0;i++)
            res *= b;
        k2 += res;
    }
    x[2] = (x[n] - k1 * x[1]) / k2;
    for(int i=3;i<=n;i++)
        x[i] = x[i-1]*a + x[i-2] *b;
    // for(int i=3;i<=n;i++)
    //     x[i] = x[i-2]*a + x[i-1] *b;
    for(int i=1;i<=n;i++)
        cout<<fixed<<setprecision(18)<<x[i]<<"\n";

}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--)
        solve();
    return 0;
}
/*
-7.37131875
0.25^4+3*0.25^2*
*/

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1.0 1.0 10 1 10

output:

1.000000000000000000
-0.323529411764705882
0.676470588235294118
0.352941176470588235
1.029411764705882353
1.382352941176470588
2.411764705882352941
3.794117647058823529
6.205882352941176470
10.000000000000000000

result:

ok 10 numbers

Test #2:

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

input:

1 1 2 1 100

output:

1.000000000000000000
100.000000000000000000

result:

ok 2 numbers

Test #3:

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

input:

1 1 5 50 100

output:

50.000000000000000000
0.000000000000000000
50.000000000000000000
50.000000000000000000
100.000000000000000000

result:

ok 5 numbers

Test #4:

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

input:

0.25 0.25 10 1 1

output:

1.000000000000000000
55.875536480686695279
14.218884120171673820
17.523605150214592275
7.935622317596566524
6.364806866952789700
3.575107296137339056
2.484978540772532189
1.515021459227467811
1.000000000000000000

result:

ok 10 numbers

Test #5:

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

input:

0.25 0.63 6 93 12

output:

93.000000000000000000
-14.204807958665044746
55.038798010333738815
4.810670488624456514
35.877110368666369579
11.999999999999999998

result:

ok 6 numbers

Test #6:

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

input:

0.25 0.80 10 5 63

output:

5.000000000000000000
78.769536183531355431
23.692384045882838858
68.938724958295794061
36.188588476280219602
64.198127085706690145
45.000402552450848220
62.608602306678064173
51.652472618630194619
62.999999999999999997

result:

ok 10 numbers

Test #7:

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

input:

0.25 0.99 3 18 30

output:

18.000000000000000000
48.720000000000000001
30.000000000000000000

result:

ok 3 numbers

Test #8:

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

input:

0.28 0.64 9 6 10

output:

6.000000000000000000
20.950403348507805111
9.706112937582185431
16.125969765568007191
10.727183814411640690
13.324232117998783995
10.596182634263109560
11.494439693112892433
9.999999999999999999

result:

ok 9 numbers

Test #9:

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

input:

0.31 0.40 7 10 49

output:

10.000000000000000000
240.115063998688263933
78.435669839593361821
120.361083249749247735
68.686203743259611525
69.437156460310178671
49.000000000000000000

result:

ok 7 numbers

Test #10:

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

input:

0.32 0.28 5 36 6

output:

36.000000000000000000
10.121376811594202899
13.318840579710144928
7.096014492753623188
6.000000000000000000

result:

ok 5 numbers

Test #11:

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

input:

0.35 0.65 10 86 82

output:

86.000000000000000000
79.533924786230832012
83.736873675180791200
81.004956897363317725
82.780702802944675478
81.626467964316792934
82.376720609424916586
81.889056390104636211
82.206038132662818452
81.999999999999999993

result:

ok 10 numbers

Test #12:

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

input:

0.36 0.68 8 72 59

output:

72.000000000000000000
38.239918642605698219
62.726370711338051360
48.584638133053573282
60.144401811609161306
54.689538582655727903
60.586427121650291733
59.000000000000000000

result:

ok 8 numbers

Test #13:

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

input:

0.43 0.61 2 93 84

output:

93.000000000000000000
84.000000000000000000

result:

ok 2 numbers

Test #14:

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

input:

0.46 0.96 6 65 35

output:

65.000000000000000000
-16.617423662818047687
54.755985115103698063
9.235026436642375331
56.813857871355042790
35.000000000000000000

result:

ok 6 numbers

Test #15:

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

input:

0.50 0.90 4 19 1

output:

19.000000000000000000
-6.565217391304347826
13.817391304347826087
1.000000000000000000

result:

ok 4 numbers

Test #16:

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

input:

0.54 0.35 3 16 22

output:

16.000000000000000000
30.370370370370370369
22.000000000000000000

result:

ok 3 numbers

Test #17:

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

input:

0.55 0.89 10 74 13

output:

74.000000000000000000
-48.321937076576519071
39.282934607882914510
-21.400909963817498992
23.191311320916169467
-6.291588641293680896
17.179893322903866332
3.849427436845750486
17.407290147649603803
13.000000000000000025

result:

ok 10 numbers

Test #18:

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

input:

0.56 0.36 3 31 88

output:

31.000000000000000000
137.214285714285714274
88.000000000000000000

result:

ok 3 numbers

Test #19:

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

input:

0.57 0.93 7 71 48

output:

71.000000000000000000
-34.080565361686018088
46.604077743838969689
-5.130601472379784100
40.417349462513764875
18.266429824319646767
47.999999999999999993

result:

ok 7 numbers

Test #20:

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

input:

0.58 0.41 8 30 69

output:

30.000000000000000000
89.432121682809812148
64.170630576029691047
73.886135624049243786
69.163917198120734721
70.408387580770216092
69.194070848076226571
69.000000000000000007

result:

ok 8 numbers

Test #21:

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

input:

0.58 0.49 6 31 96

output:

31.000000000000000000
99.557613538417172448
72.933415852281960022
91.084611828147951311
88.566448627943972174
96.000000000000000000

result:

ok 6 numbers

Test #22:

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

input:

0.61 0.29 8 62 25

output:

62.000000000000000000
34.407651257133715316
38.968667266851566344
33.749105897348232911
31.887868104769376316
29.238840254140307098
27.083174305408706461
25.000000000000000000

result:

ok 8 numbers

Test #23:

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

input:

0.63 0.89 9 37 85

output:

37.000000000000000000
-5.887853302176883510
29.220652419628563390
13.168821585428568611
34.302738252289419640
33.330976309973760437
51.527952119821052557
62.127178751363909895
85.000000000000000007

result:

ok 9 numbers

Test #24:

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

input:

0.64 0.67 2 74 42

output:

74.000000000000000000
42.000000000000000000

result:

ok 2 numbers

Test #25:

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

input:

0.65 0.56 2 94 96

output:

94.000000000000000000
96.000000000000000000

result:

ok 2 numbers

Test #26:

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

input:

0.65 0.90 10 97 23

output:

97.000000000000000000
-61.703576279117554285
47.192675418573589712
-24.857979629132965544
26.315721117779803136
-5.266962939662796951
20.260623095221004804
8.429138366197135867
23.713500723727042636
22.999999999999999993

result:

ok 10 numbers

Test #27:

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

input:

0.67 0.88 4 70 42

output:

70.000000000000000000
0.547821506509142898
61.967040409361125741
41.999999999999999997

result:

ok 4 numbers

Test #28:

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

input:

0.69 0.39 10 2 27

output:

2.000000000000000000
22.365907687016125738
16.212476304041126760
19.909312647724666502
20.060291485506059322
21.606233057611800867
22.731814489099505734
24.111382889947261294
25.502261844812417528
26.999999999999999998

result:

ok 10 numbers

Test #29:

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

input:

0.69 0.57 4 88 47

output:

88.000000000000000000
11.843609597552815220
58.332090622311442502
47.000000000000000000

result:

ok 4 numbers

Test #30:

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

input:

0.71 0.89 8 4 41

output:

4.000000000000000000
6.838890362691071826
8.415612157510660996
12.061697054627623231
16.053699728970100780
22.133037186187356229
30.002249160976412616
41.000000000000000000

result:

ok 8 numbers

Test #31:

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

input:

0.72 0.49 8 21 48

output:

21.000000000000000000
19.940442369940301316
24.647118506357016949
27.516742085847799848
31.889142369925354198
36.443386128411676947
41.864917773719830960
47.999999999999999997

result:

ok 8 numbers

Test #32:

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

input:

0.74 0.58 3 57 29

output:

57.000000000000000000
-5.486486486486486484
29.000000000000000000

result:

ok 3 numbers

Test #33:

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

input:

0.76 0.70 2 91 18

output:

91.000000000000000000
18.000000000000000000

result:

ok 2 numbers

Test #34:

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

input:

0.77 0.36 10 31 25

output:

31.000000000000000000
5.214972085026422368
15.175528505470345224
13.562546899821677875
15.906351374832016245
17.130407442556456544
18.916700225707997387
20.732805853115482343
22.774272588153800463
25.000000000000000000

result:

ok 10 numbers

Test #35:

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

input:

0.77 0.96 8 78 68

output:

78.000000000000000000
-40.097557007604979297
44.004881104144165940
-4.609896277109772351
38.695065726603874591
25.369700183459601976
56.681932238803613130
68.000000000000000007

result:

ok 8 numbers

Test #36:

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

input:

0.78 0.52 7 73 77

output:

73.000000000000000000
8.727547506052932295
44.767487054721287188
39.456964605830128798
54.055525661002569799
62.680931610613671415
77.000000000000000000

result:

ok 7 numbers

Test #37:

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

input:

0.78 0.69 4 42 97

output:

42.000000000000000000
57.297905113986444859
73.672365988909426990
97.000000000000000000

result:

ok 4 numbers

Test #38:

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

input:

0.78 0.70 10 54 99

output:

54.000000000000000000
-13.012886350899695975
27.649948646298237138
12.457939498482837785
29.072156861225379468
31.396840000693782433
44.840045003398915923
56.953023103136802122
75.811389522825946799
98.999999999999999986

result:

ok 10 numbers

Test #39:

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

input:

0.78 0.76 10 97 83

output:

97.000000000000000000
-43.734736959040487601
39.606905171948419673
-2.345014054751003232
28.272136967975016431
20.270056153409750359
37.297467895320617768
44.497267634941492131
63.053944355698033367
83.000000000000000042

result:

ok 10 numbers

Test #40:

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

input:

0.78 0.95 10 100 32

output:

100.000000000000000000
-63.269578817364127810
45.649728522455980312
-24.499311628980256775
24.257779025728581012
-4.353278407462950748
19.649332916621050377
11.190865187874616083
27.395741117332198402
32.000000000000000031

result:

ok 10 numbers

Test #41:

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

input:

0.79 0.90 10 98 42

output:

98.000000000000000000
-58.246914628041362088
42.184937443847323947
-19.096122584597839959
22.880506857630297984
0.889090091389879445
21.294837344065272948
17.623102584062457129
33.087604651068086785
41.999999999999999976

result:

ok 10 numbers

Test #42:

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

input:

0.81 0.48 10 97 1

output:

97.000000000000000000
-38.257501681599215940
15.571423637904635085
-5.750747660464869231
2.816177741217680763
-0.479254906636815813
0.963568841408665958
0.550448406355347836
0.908376253023991406
1.000000000000000000

result:

ok 10 numbers

Test #43:

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

input:

0.81 0.86 10 20 100

output:

20.000000000000000000
-3.332842869651401584
14.500397275582364718
8.879076925321510059
19.662393966511256805
23.562545268650616662
35.995320478806680349
49.419998518872941415
70.986174412060827649
100.000000000000000014

result:

ok 10 numbers

Test #44:

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

input:

0.84 0.85 10 74 95

output:

74.000000000000000000
-36.290804877098289942
32.415723903237436451
-3.617976066814099834
24.514265421627977124
17.516703297375515925
35.551156378179213931
44.752169160439728236
67.810305016221703561
94.999999999999999986

result:

ok 10 numbers

Test #45:

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

input:

0.88 0.37 10 3 96

output:

3.000000000000000000
29.021828490376422992
26.649209071531252234
34.189380524386778472
39.946862217926928380
47.803309545798805008
56.847251420935911909
67.712805782369160333
80.620752114231148497
96.000000000000000000

result:

ok 10 numbers

Test #46:

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

input:

0.91 0.50 10 100 98

output:

100.000000000000000000
-22.586857854484423579
29.445959352419174542
15.502394083459237044
28.830158292157492981
33.986641087592937137
45.342922535788319285
58.255380051363839119
75.683857114635253241
98.000000000000000014

result:

ok 10 numbers

Test #47:

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

input:

0.94 0.48 10 44 97

output:

44.000000000000000000
-1.582743438717806901
19.632221167605261512
17.694571046964398508
26.056362944597060122
32.986375270464147798
43.514246967642887791
56.736852279407105466
74.219479687111265281
96.999999999999999993

result:

ok 10 numbers

Test #48:

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

input:

0.94 0.54 10 28 95

output:

28.000000000000000000
0.452546307145840479
15.545393528717090051
14.857044922852818507
22.360134732988878025
29.041330907350067340
39.373323808723057433
52.693243070168710351
70.793243342669038745
95.000000000000000007

result:

ok 10 numbers

Test #49:

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

input:

0.95 0.57 10 2 94

output:

2.000000000000000000
9.227284174161059790
9.905919965453006800
14.670175946452160540
19.583041529437766388
26.965889742443609575
36.779928927100955939
50.311489633938765602
68.760474640689372205
93.999999999999999986

result:

ok 10 numbers

Test #50:

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

input:

0.98 0.90 10 21 99

output:

21.000000000000000000
-8.213193484970175353
10.851070384729228154
3.242174840561485773
12.943294690006561395
15.602386152711767363
26.939303650663437271
40.442665115090759152
63.879185098386037513
99.000000000000000000

result:

ok 10 numbers

Extra Test:

score: 0
Extra Test Passed