Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- const int MAXN = 100 * 1000 + 5;
- const long double EPS = 1e-9;
- long double a[MAXN], b[MAXN], p[MAXN], q[MAXN];
- pair<long double, long double> solve(long double p, long double q) {
- long double d = sqrt(p * p - 4 * q);
- return make_pair((-p + d) / 2, (-p - d) / 2);
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.setf(ios::fixed);
- cout.precision(9);
- int n;
- cin >> n;
- for(int i = 0; i < n; i++)
- cin >> a[i];
- for(int i = 0; i < n; i++)
- cin >> b[i];
- for(int i = 0; i + 1 < n; i++)
- a[i + 1] += a[i];
- for(int i = n - 1; i > 0; i--)
- b[i - 1] += b[i];
- for(int i = 0; i < n; i++) {
- pair<long double, long double> pp = solve(b[i + 1] - a[i] - 1, a[i]);
- p[i] = pp.first;
- q[i] = pp.second;
- }
- for(int i = 0; i < n; i++)
- cout << p[i] - (i? p[i - 1] : 0) << ' ';
- cout << '\n';
- for(int i = 0; i < n; i++)
- cout << q[i] - (i? q[i - 1] : 0) << ' ';
- cout << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement