QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623024 | #8795. Mysterious Sequence | rns_rds# | WA | 0ms | 3956kb | C++23 | 833b | 2024-10-09 09:39:47 | 2024-10-09 09:39:48 |
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 = 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
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: 3864kb
input:
1 1 2 1 100
output:
1.000000000000 100.000000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
1 1 5 50 100
output:
50.000000000000 -0.000000007105 49.999999992895 49.999999985789 100.000000000000
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
0.25 0.25 10 1 1
output:
1.000000000000 55.875536475014 14.218884118754 17.523605148442 7.935622316799 6.364806866310 3.575107295777 2.484978540522 1.515021459075 1.000000000000
result:
ok 10 numbers
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3956kb
input:
0.25 0.63 6 93 12
output:
93.000000000000 -2.196895160012 21.865956049193 13.226328520989 13.799075980521 12.000000000000
result:
wrong answer 2nd numbers differ - expected: '-14.2048080', found: '-2.1968952', error = '0.8453414'