QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#540921 | #8795. Mysterious Sequence | Nanani# | WA | 0ms | 3920kb | C++20 | 1.2kb | 2024-08-31 18:08:49 | 2024-08-31 18:08:50 |
Judging History
answer
//by 72
#include<bits/stdc++.h>
#define F(i, a, b) for(int i = a; i <= b; i ++)
#define Fd(i, a, b) for(int i = a; i >= b; i --)
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define int long long
using namespace std;
const int mod = 998244353;
const int N = 2e5 + 10;
const int inf = 1e18;
typedef array<int, 3> a3;
typedef long long ll;
int n;
double A, B, x1, xn;
const double eps = 1e-8;
double f[20];
double cal(double x) {
f[1] = x1, f[2] = x;
F(i, 3, n) f[i] = A * f[i - 1] + B * f[i - 2];
return f[n];
}
void sol() {
cout << fixed << setprecision(20);
cin >> A >> B;
cin >> n >> x1 >> xn;
if(n == 2) {
cout << x1 << "\n" << xn << "\n";
return;
}
double l = -100, r = 100;
while(r - l > eps) {
double mid = (r + l) / 2;
if(cal(mid) < xn) l = mid;
else r = mid;
}
f[1] = x1, f[2] = l;
F(i, 3, n) f[i] = A * f[i - 1] + B * f[i - 2];
F(i, 1, n) cout << f[i] << "\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
F(i, 1, t) sol();
return 0;
}
//sldl
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
input:
1.0 1.0 10 1 10
output:
1.00000000000000000000 -0.32352941343560814857 0.67647058656439185143 0.35294117312878370285 1.02941175969317555428 1.38235293282195925713 2.41176469251513481140 3.79411762533709406853 6.20588231785222887993 9.99999994318932294846
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
1 1 2 1 100
output:
1.00000000000000000000 100.00000000000000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
1 1 5 50 100
output:
50.00000000000000000000 -0.00000000582076609135 49.99999999417923390865 49.99999998835846781731 99.99999998253770172596
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
0.25 0.25 10 1 1
output:
1.00000000000000000000 55.87553647928871214390 14.21888411982217803597 17.52360514977772254497 7.93562231739997514524 6.36480686679442442255 3.57510729604859989195 2.48497854071075607862 1.51502145918983899264 0.99999999997514876782
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
0.25 0.63 6 93 12
output:
93.00000000000000000000 -14.20480796368792653084 55.03879800907802177790 4.81067048514611173005 35.87711036700568456581 11.99999999739347167349
result:
ok 6 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
0.25 0.80 10 5 63
output:
5.00000000000000000000 78.76953618251718580723 23.69238404562929645181 68.93872495742107275873 36.18858847585870819330 64.19812708490154307128 45.00040255191235871735 62.60860230589932484691 51.65247261800472244886 62.99999999922064830571
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
0.25 0.99 3 18 30
output:
18.00000000000000000000 48.71999999741092324257 29.99999999935273109486
result:
ok 3 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.28 0.64 9 6 10
output:
6.00000000000000000000 20.95040334388613700867 9.70611293628811822032 16.12596976224780220832 10.72718381265378084777 13.32423211538165119805 10.59618263240528257541 11.49443969091773709579 9.99999999819634766141
result:
ok 9 numbers
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3828kb
input:
0.31 0.40 7 10 49
output:
10.00000000000000000000 99.99999999417923390865 34.99999999819556251168 50.84999999711232021582 29.76349999838304682953 29.56668499834367480616 21.07107234883975976913
result:
wrong answer 2nd numbers differ - expected: '240.1150640', found: '100.0000000', error = '0.5835330'