Cod sursa(job #1105393)

Utilizator L.DanielLungu Daniel L.Daniel Data 11 februarie 2014 19:30:53
Problema Dezastru Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <fstream>
#include <iomanip>
using namespace std;
int n, k, nc;
double v[26],a[26][26],b[26][26];
int main()
{
	ifstream cin("dezastru.in");
	ofstream cout("dezastru.out");
	cin >> n >> k; 
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	for (int i = 0; i <= 25; ++i)
	{
		a[i][0] = 1.0;
		b[i][0] = 1.0;
	}


	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= k; ++j)
		{
			a[i][j] = a[i - 1][j] + a[i - 1][j - 1] * v[i];
			b[i][j] = b[i - 1][j] + b[i - 1][j - 1];
		}
	}
	cout << setprecision(6)<< a[n][k]/b[n][k];
	return 0;
}