QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#497521 | #8795. Mysterious Sequence | lulujia5454# | WA | 0ms | 3880kb | C++20 | 1.1kb | 2024-07-29 12:33:32 | 2024-07-29 12:33:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define mem(trie, a) memset((trie), (a), sizeof(trie))
const int N = 1e2 + 10;
double a[N], b[N];
int n;
double aa, bb;
int check(double x)
{
b[1] = a[1];
b[2] = x;
for (int i = 3; i <= n; i++)
{
b[i] = b[i - 2] * aa + b[i - 1] * bb;
}
return b[n] > a[n];
}
void solve()
{
cin >> aa >> bb >> n;
cin >> a[1] >> a[n];
double l = -1e5, r = 1e5;
while (fabs(r - l) > 1e-9)
{
double mid = (l + r) / 2;
if (check(mid))
r = mid;
else
l = mid;
}
b[1] = a[1];
b[2] = l;
for (int i = 3; i <= n; i++)
{
b[i] = b[i - 2] * aa + b[i - 1] * bb;
}
for (int i = 1; i <= n; i++)
{
cout <<fixed<<setprecision(6)<< b[i] << endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3880kb
input:
1.0 1.0 10 1 10
output:
1.000000 -0.323529 0.676471 0.352941 1.029412 1.382353 2.411765 3.794118 6.205882 10.000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
1 1 2 1 100
output:
1.000000 100.000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
1 1 5 50 100
output:
50.000000 0.000000 50.000000 50.000000 100.000000
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
0.25 0.25 10 1 1
output:
1.000000 55.875536 14.218884 17.523605 7.935622 6.364807 3.575107 2.484979 1.515021 1.000000
result:
ok 10 numbers
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3860kb
input:
0.25 0.63 6 93 12
output:
93.000000 -2.196895 21.865956 13.226329 13.799076 12.000000
result:
wrong answer 2nd numbers differ - expected: '-14.2048080', found: '-2.1968950', error = '0.8453415'