Task: | Approximate |
Sender: | Game of Nolife |
Submission time: | 2016-05-28 11:08:29 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.18 s | details |
Code
#include <bits/stdc++.h>#define F first#define S second#define X real()#define Y imag()using namespace std;typedef long long ll;typedef long double ld;ld x[1010101];ld xx[1010101];int main(){ios_base::sync_with_stdio(0);cin.tie(0);int n,q;cin>>n>>q;for (int i=1;i<=n;i++) {cin>>x[i];xx[i]=x[i]*x[i];x[i]+=x[i-1];xx[i]+=xx[i-1];}cout<<setprecision(6)<<fixed;for (int i=0;i<q;i++) {int a,b;cin>>a>>b;ld y1=(x[b]-x[a-1])/(b-a+1);ld y2=(xx[b]-xx[a-1])/(b-a+1);cout<<y2-y1*y1<<"\n";}}