Cod sursa(job #1879994)
| Utilizator | Data | 15 februarie 2017 12:25:21 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <cstdio>
#define N 26
using namespace std;
double p[N], ans=0;
int l=0;
int main()
{
freopen("dezastru.in", "r", stdin);
freopen("dezastru.out", "w", stdout);
int i, n, k, j;
scanf("%d%d", &n, &k);
for(i=1; i<=n; ++i)
scanf("%lf", &p[i]);
for(i=1;i<=n-k+1;i++)
for(j=i+1;j<=i+k;j++){
ans+=p[i]*p[j];
l++;
}
printf("%lf ", ans/(l-1));
return 0;
}
