QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#440461 | #8795. Mysterious Sequence | chenjiaqiy | WA | 0ms | 4008kb | C++20 | 1.0kb | 2024-06-13 19:04:16 | 2024-06-13 19:04:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define endl '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define x first
#define y second
#define debug(_x) cout << #_x << '=' << _x << endl
typedef pair<int, int> PII;
using i64 = long long;
const int mod = 1e9 + 7;
const int N = 100 + 10;
void solve()
{
double a, b, X1, Xn;
int n;
cin >> a >> b >> n >> X1 >> Xn;
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] : 0);
}
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;
}
cout << fixed << setprecision(10);
for (int i = 0; i < n; i++)
{
cout << X[i] << "\n";
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int _ = 1;
// cin >> _;
while (_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
1.0 1.0 10 1 10
output:
1.0000000000 -0.3235294118 0.6764705882 0.3529411765 1.0294117647 1.3823529412 2.4117647059 3.7941176471 6.2058823529 10.0000000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 1 2 1 100
output:
1.0000000000 100.0000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 4008kb
input:
1 1 5 50 100
output:
50.0000000000 0.0000000000 50.0000000000 50.0000000000 100.0000000000
result:
ok 5 numbers
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3868kb
input:
0.25 0.25 10 1 1
output:
1.0000000000 -0.0962254072 0.2259436482 0.0324295602 0.0645933021 0.0242557156 0.0222122544 0.0116169925 0.0084573117 0.0050185761
result:
wrong answer 2nd numbers differ - expected: '55.8755365', found: '-0.0962254', error = '1.0017221'