QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#497552#8795. Mysterious SequenceemtWA 0ms4012kbC++142.4kb2024-07-29 13:31:542024-07-29 13:31:54

Judging History

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

  • [2024-07-29 13:31:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4012kb
  • [2024-07-29 13:31:54]
  • 提交

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-2]*a + x[i-1] *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;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3820kb

input:

1 1 2 1 100

output:

1.000000000000000000
100.000000000000000000

result:

ok 2 numbers

Test #3:

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

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: 4012kb

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: -100
Wrong Answer
time: 0ms
memory: 3852kb

input:

0.25 0.63 6 93 12

output:

93.000000000000000000
-14.204807958665044746
14.300970986041021810
5.458409731539582554
7.014040877380192461
5.783448185634416889

result:

wrong answer 3rd numbers differ - expected: '55.0387980', found: '14.3009710', error = '0.7401656'