QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623008 | #8795. Mysterious Sequence | rns_rds# | WA | 0ms | 3916kb | C++23 | 817b | 2024-10-09 09:33:03 | 2024-10-09 09:33:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define double long double
void solve() {
const double inf = 1e6;
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 = fi + 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 = x + lo;
x = lo, lo = tmp;
}
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: 0ms
memory: 3856kb
input:
1.0 1.0 10 1 10
output:
1.000000000000 -0.323529413038 0.676470586962 0.352941173925 1.029411760887 1.382352934811 2.411764695698 3.794117630510 6.205882326208 10.000000000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
1 1 2 1 100
output:
1.000000000000 100.000000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 1 5 50 100
output:
50.000000000000 -0.000000007105 49.999999992895 49.999999985789 100.000000000000
result:
ok 5 numbers
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3916kb
input:
0.25 0.25 10 1 1
output:
1.000000000000 -0.588235295140 0.411764704860 -0.176470590281 0.235294114579 0.058823524299 0.294117638878 0.352941163176 0.647058802054 1.000000000000
result:
wrong answer 2nd numbers differ - expected: '55.8755365', found: '-0.5882353', error = '1.0105276'