Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define endl "\n"
- using namespace std;
- using ll = long long;
- using ld = long double;
- using pii = pair<int, int>;
- constexpr int N = 1e5 + 5;
- vector<ld> pref;
- int n, q, l, r;
- ld get(ld cl, ld cr) {
- return (cr - cl + 1) / (pref[cr] - pref[cl - 1]);
- }
- void Solve() {
- cin >> n;
- pref.resize(n + 1);
- pref[0] = 0;
- for (int i = 1; i <= n; i++) {
- cin >> pref[i];
- pref[i] = 1 / pref[i];
- pref[i] += pref[i - 1];
- }
- cin >> q;
- while(q--) {
- cin >> l >> r;
- l++, r++;
- cout << fixed << setprecision(20) << get(l, r) << endl;
- }
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- // cin >> t;
- // while(t--)
- //auto start = chrono::high_resolution_clock::now();
- Solve();
- //auto end = chrono::high_resolution_clock::now();
- //cout << endl << (chrono::duration_cast<chrono::duration<double>>(end - start)).count();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement