QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#673 | #432733 | #8795. Mysterious Sequence | ucup-team3535 | ucup-team004 | Failed. | 2024-06-10 20:04:21 | 2024-06-10 20:04:22 |
Details
Extra Test:
Accepted
time: 0ms
memory: 3924kb
input:
0.99 0.99 10 1 1
output:
1.0000000000 -0.5847052569 0.4111417957 -0.1718278267 0.2369208293 0.0644420726 0.2983492729 0.3591634321 0.6509375780 1.0000000000
result:
ok 10 numbers
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#432733 | #8795. Mysterious Sequence | ucup-team004# | AC ✓ | 1ms | 4036kb | C++20 | 724b | 2024-06-07 16:14:56 | 2024-06-07 16:14:57 |
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
double A, B, X1, Xn;
int n;
std::cin >> A >> B >> n >> X1 >> Xn;
std::vector<double> f(n);
f[0] = 1;
for (int i = 1; i < n; i++) {
f[i] = f[i - 1] * A + (i >= 2 ? f[i - 2] * B : 0);
}
std::vector<double> X(n);
X[0] = X1;
X[1] = (Xn - X1 * f[n - 1]) / f[n - 2] + X1 * A;
for (int i = 2; i < n; i++) {
X[i] = X[i - 1] * A + X[i - 2] * B;
}
std::cout << std::fixed << std::setprecision(10);
for (int i = 0; i < n; i++) {
std::cout << X[i] << "\n";
}
return 0;
}