QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#487219 | #8795. Mysterious Sequence | ucup-team4435# | WA | 1ms | 3720kb | C++20 | 999b | 2024-07-22 18:28:50 | 2024-07-22 18:28:50 |
Judging History
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';
}
}
Details
Tip: Click on the bar to expand more detailed information
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'