QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#554132 | #8795. Mysterious Sequence | ucup-team3931# | WA | 0ms | 4044kb | C++20 | 1.1kb | 2024-09-09 07:39:46 | 2024-09-09 07:39:47 |
Judging History
answer
#ifdef LOCAL
#include "stdafx.h"
#else
#include <bits/stdc++.h>
#define IL inline
#define LL long long
#define eb emplace_back
#define sz(v) ((int) (v).size())
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;
using vi = vector<int>;
#endif
using db = double;
int n;
db A, B, x0, x1;
int main () {
ios::sync_with_stdio(0), cin.tie(0);
cout << fixed << setprecision(7);
cin >> A >> B >> n >> x0 >> x1;
db a = (A + sqrtl(A * A + 4 * B)) / 2;
db b = (A - sqrtl(A * A + 4 * B)) / 2;
db aa = powl(a, n);
db bb = powl(b, n);
db c2 = (a * x1 - aa * x0) / (a * bb - aa * b);
db c1 = (b * x1 - bb * x0) / (b * aa - bb * a);
assert((x0 - c1 * a - c2 * b) < 1e-7);
assert((x1 - c1 * aa - c2 * bb) < 1e-7);
db fst = x0;
db scd = c1 * a * a + c2 * b * b;
cout << fst << '\n' << scd << '\n';
L (i, 3, n) {
db cur = fst * A + scd * B;
cout << cur << '\n';
fst = scd;
scd = cur;
}
}
// I love WHQ!
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4044kb
input:
1.0 1.0 10 1 10
output:
1.0000000 -0.3235294 0.6764706 0.3529412 1.0294118 1.3823529 2.4117647 3.7941176 6.2058824 10.0000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
1 1 2 1 100
output:
1.0000000 100.0000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 1 5 50 100
output:
50.0000000 -0.0000000 50.0000000 50.0000000 100.0000000
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
0.25 0.25 10 1 1
output:
1.0000000 55.8755365 14.2188841 17.5236052 7.9356223 6.3648069 3.5751073 2.4849785 1.5150215 1.0000000
result:
ok 10 numbers
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3844kb
input:
0.25 0.63 6 93 12
output:
93.0000000 -14.2048080 14.3009710 5.4584097 7.0140409 5.7834482
result:
wrong answer 3rd numbers differ - expected: '55.0387980', found: '14.3009710', error = '0.7401656'