QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#623035 | #8795. Mysterious Sequence | rns_rds# | WA | 1ms | 3936kb | C++23 | 833b | 2024-10-09 09:44:04 | 2024-10-09 09:44:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define double long double
void solve() {
const double inf = 1e9;
const double ep = 1e-8;
double a, b;
cin >> a >> b;
int n;
cin >> n;
double x, y;
cin >> x >> y;
double lo = -inf, hi = inf;
auto calc = [&](double val) {
double fi = x, se = val;
for (int i = 3; i <= n; i++) {
double tmp = a * fi + b * se;
fi = se, se = tmp;
}
return se;
};
while (hi > lo + ep) {
double mid = (hi + lo) / 2;
if (calc(mid) < y) lo = mid;
else hi = mid;
}
cout << setprecision(12) << fixed;
cout << x << "\n";
for (int i = 2; i < n; i++) {
cout << lo << "\n";
double tmp = a * x + b * lo;
x = lo, lo = tmp;
}
cout << y << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3828kb
input:
1.0 1.0 10 1 10
output:
1.000000000000 -0.323529418533 0.676470581467 0.352941162933 1.029411744400 1.382352907333 2.411764651734 3.794117559067 6.205882210801 10.000000000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 3936kb
input:
1 1 2 1 100
output:
1.000000000000 100.000000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
1 1 5 50 100
output:
50.000000000000 -0.000000006939 49.999999993061 49.999999986122 100.000000000000
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
0.25 0.25 10 1 1
output:
1.000000000000 55.875536475458 14.218884118865 17.523605148581 7.935622316861 6.364806866360 3.575107295805 2.484978540541 1.515021459087 1.000000000000
result:
ok 10 numbers
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3936kb
input:
0.25 0.63 6 93 12
output:
93.000000000000 -2.196895158846 21.865956049927 13.226328521743 13.799075981180 12.000000000000
result:
wrong answer 2nd numbers differ - expected: '-14.2048080', found: '-2.1968952', error = '0.8453414'