QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#497522 | #8795. Mysterious Sequence | lulujia5454# | WA | 0ms | 3928kb | C++20 | 1.1kb | 2024-07-29 12:37:14 | 2024-07-29 12:37:15 |
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 = -1e9, r = 1e9;
while (fabs(r - l) > 1e-10)
{
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(9)<< 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
input:
1.0 1.0 10 1 10
output:
1.000000000 -0.323529412 0.676470588 0.352941176 1.029411765 1.382352941 2.411764706 3.794117646 6.205882352 9.999999998
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1 1 2 1 100
output:
1.000000000 100.000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
1 1 5 50 100
output:
50.000000000 0.000000000 50.000000000 50.000000000 100.000000000
result:
ok 5 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
0.25 0.25 10 1 1
output:
1.000000000 55.875536481 14.218884120 17.523605150 7.935622318 6.364806867 3.575107296 2.484978541 1.515021459 1.000000000
result:
ok 10 numbers
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3832kb
input:
0.25 0.63 6 93 12
output:
93.000000000 -2.196895156 21.865956052 13.226328523 13.799075983 12.000000000
result:
wrong answer 2nd numbers differ - expected: '-14.2048080', found: '-2.1968952', error = '0.8453414'