QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#440352 | #8795. Mysterious Sequence | HKOI0# | WA | 1ms | 3876kb | C++14 | 815b | 2024-06-13 16:38:20 | 2024-06-13 16:38:21 |
Judging History
answer
#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define int long long
using namespace std;
struct Num{
double a1, a2;
Num operator* (double A) {
return {a1 * A, a2 * A};
}
Num operator+ (Num a) {
return {a1 + a.a1, a2 + a.a2};
}
};
void solve(){
double A, B; int n; double X1, XN;
cin >> A >> B >> n >> X1 >> XN;
vector<Num> V;
V.push_back({1, 0});
V.push_back({0, 1});
for (int i = 3; i <= n; i++) {
V.push_back(V[i - 3] * A + V[i - 2] * B);
}
double X2 = (XN - V.back().a1 * X1) / V.back().a2;
cout << fixed << setprecision(10);
for (auto [a, b] : V) {
cout << X1 * a + X2 * b << '\n';
}
}
int32_t main(){
#ifndef LOCAL
cin.tie(0); cout.tie(0)->sync_with_stdio(false);
#endif
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3788kb
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: 1ms
memory: 3728kb
input:
1 1 2 1 100
output:
1.0000000000 100.0000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
1 1 5 50 100
output:
50.0000000000 0.0000000000 50.0000000000 50.0000000000 100.0000000000
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
0.25 0.25 10 1 1
output:
1.0000000000 55.8755364807 14.2188841202 17.5236051502 7.9356223176 6.3648068670 3.5751072961 2.4849785408 1.5150214592 1.0000000000
result:
ok 10 numbers
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3796kb
input:
0.25 0.63 6 93 12
output:
93.0000000000 -2.1968951561 21.8659560517 13.2263285235 13.7990759827 12.0000000000
result:
wrong answer 2nd numbers differ - expected: '-14.2048080', found: '-2.1968952', error = '0.8453414'