QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#630040#8795. Mysterious Sequenceqianchen06#RE 0ms0kbC++141.3kb2024-10-11 16:08:072024-10-11 16:08:09

Judging History

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

  • [2024-10-11 16:08:09]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-11 16:08:07]
  • 提交

answer

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

const double eps = 1e-7;
void solve()
{
    double a, b;
    int n;
    vector<double> x(n + 1);
    cin >> a >> b >> n >> 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();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

1.0 1.0 10 1 10

output:


result: