QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#622987 | #8795. Mysterious Sequence | rns_rds# | WA | 1ms | 3928kb | C++23 | 836b | 2024-10-09 09:24:00 | 2024-10-09 09:24:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define double long double
void solve() {
const double inf = 1e3;
const double ep = 1e-9;
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 = fi + se;
fi = se, se = tmp;
}
return se;
};
while (hi > lo + ep) {
double mid = (hi + lo) / 2;
if (calc(mid) + ep < y) lo = mid;
else hi = mid;
}
cout << setprecision(12) << fixed;
cout << x << "\n" << lo << "\n";
for (int i = 3; i < n; i++) {
double tmp = x + lo;
x = lo, lo = tmp;
cout << lo << "\n";
}
cout << y << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3684kb
input:
1.0 1.0 10 1 10
output:
1.000000000000 -0.323529412526 0.676470587474 0.352941174948 1.029411762422 1.382352937369 2.411764699791 3.794117637161 6.205882336952 10.000000000000
result:
ok 10 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3928kb
input:
1 1 2 1 100
output:
1.000000000000 99.999999998545 100.000000000000
result:
wrong output format Extra information in the output file