# HIIT Open 2016

 Start: 2016-05-28 11:00:00 End: 2016-05-28 16:00:00

CSES - HIIT Open 2016 - Results
History
2016-05-28 11:45:25
2016-05-28 11:44:26
2016-05-28 11:41:26
 Task: Approximate Sender: Noname 01 Submission time: 2016-05-28 11:45:25 Language: C++ Status: READY Result: ACCEPTED

## Test results

 test verdict time (s) #1 ACCEPTED 0.16 / 1.00 details

## Code

```// NONAME-01

#include <bits/stdc++.h>

using namespace std;

vector <int> a;
vector <long long> x;
vector <long long> xx;
int n, m;

{
cin >> n >> m;
int i;
a.resize(n); x.resize(n); xx.resize(n);
for (i = 0; i < n; i++) {
cin >> a[i];
if (i > 0) x[i] += x[i-1];
x[i] += a[i];
if (i > 0) xx[i] += xx[i-1];
xx[i] += a[i]*a[i];
}
}

void Solve()
{
int i, a, b;
for (i = 0; i < m; i++) {
cin >> a >> b;
a--;
b--;
long long s, ss;
s = x[b];
if (a > 0) s -= x[a-1];
ss = xx[b];
if (a > 0) ss -= xx[a-1];
long double l = b-a+1;
// cerr << s << ' ' << ss << ' ' << l << "\n";
long double ans = 1/l * (ss - s*(s/l));
cout.precision(6);
cout.setf(ios::fixed);
cout << ans << "\n";

}

}

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
Solve();
return 0;
}```

## Test details

### Test 1

Verdict: ACCEPTED

input
```100000 100000 62 64 35 47 57 38 52 4 56 13 7...```
view   save

correct output
```831.753342 833.361649 833.847478 834.425131 831.468120 836.550284 840.319891 843.709808 830.097515 832.352323 828.549331 811.748878 833.912525 830.245034 831.485429 815.101051 834.579010 848.833782 839.942329 822.449380 ...```
view   save

user output
```831.753342 833.361649 833.847478 834.425131 831.468120 836.550284 840.319891 843.709808 830.097515 832.352323 828.549331 811.748878 833.912525 830.245034 831.485429 815.101051 834.579010 848.833782 839.942329 822.449380 ...```
view   save