QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#433813 | #8795. Mysterious Sequence | ucup-team2010# | WA | 0ms | 4052kb | C++17 | 1.5kb | 2024-06-08 13:34:52 | 2024-06-08 13:34:52 |
Judging History
answer
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
#define LNF 0x3f3f3f3f3f3f3f3f
void W() {} template<class T, class... U> void W(const T &head, const U &... tail) { cerr << "#" << head; cerr << (sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class A>void udp(T &a, A b) { if (a < b)a = b;}
#define pb push_back
void solve(void) {
long double A, B, X1, Xn;
ll n;
cin >> A >> B >> n >> X1 >> Xn;
std::vector<pair<long double, long double>> ans(n + 3);
ans[1] = {0, 1};
ans[2] = {1, 0};
cout<<fixed<<setprecision(10);
if(n==2){
cout<<fixed<<setprecision(10);
cout<<X1<<"\n";
cout<<Xn;
return;
}
for (int i = 3; i <= n; i++) {
long double xa = ans[i - 1].second * A + ans[i - 2].second * B;
long double xb = ans[i - 1].first * A + ans[i - 2].first * B;
ans[i] = {xb, xa};
}
long double w = (Xn - ans[n].second * X1) / (B*ans[n].first);
cout<<X1<<"\n";
cout<<w<<"\n";
for (int i = 3; i <= n; i++) {
long double now = ans[i].second * X1 + ans[i].first * w;
cout << fixed << setprecision(10) << now << "\n";
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
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: 3956kb
input:
1.0 1.0 10 1 10
output:
1.0000000000 -0.3235294118 0.6764705882 0.3529411765 1.0294117647 1.3823529412 2.4117647059 3.7941176471 6.2058823529 10.0000000000
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
1 1 2 1 100
output:
1.0000000000 100.0000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 4052kb
input:
1 1 5 50 100
output:
50.0000000000 0.0000000000 50.0000000000 50.0000000000 100.0000000000
result:
ok 5 numbers
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3888kb
input:
0.25 0.25 10 1 1
output:
1.0000000000 223.5021459227 56.1255364807 69.9069206009 31.5081142704 25.3537587178 14.2154682470 9.8923067412 6.0269437471 3.9798126221
result:
wrong answer 2nd numbers differ - expected: '55.8755365', found: '223.5021459', error = '3.0000000'