QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#487219#8795. Mysterious Sequenceucup-team4435#WA 1ms3720kbC++20999b2024-07-22 18:28:502024-07-22 18:28:50

Judging History

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

  • [2024-07-22 18:28:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2024-07-22 18:28:50]
  • 提交

answer

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

using ll = long long;
using ld = long double;

#define all(a) begin(a), end(a)
#define len(a) int((a).size())

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    ld a, b;
    cin >> a >> b;

    int n;
    cin >> n;

    vector<ld> x(n);
    cin >> x[0] >> x[n - 1];

    if (n > 2) {
        vector<pair<ld, ld>> pres(n); // k * x[1] + b
        pres[0] = {0, x[0]};
        pres[1] = {1, 0};
        for (int i = 2; i < n; i++) {
            pres[i].first = pres[i - 1].first * a + pres[i - 2].first * b;
            pres[i].second = pres[i - 1].second * a + pres[i - 2].second * b;
        }

        ld diff = x[n - 1] - pres[n - 1].second;
        if (fabs(diff) > 1e-9) {
            x[1] = diff / pres[n - 1].first;
        }

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

    for (auto x : x) {
        cout << x << '\n';
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3720kb

input:

1.0 1.0 10 1 10

output:

1
-0.323529
0.676471
0.352941
1.02941
1.38235
2.41176
3.79412
6.20588
10

result:

wrong answer 5th numbers differ - expected: '1.0294118', found: '1.0294100', error = '0.0000017'