Pagini recente » Cod sursa (job #468149) | Cod sursa (job #783811) | Cod sursa (job #2102310) | Cod sursa (job #1808934) | Cod sursa (job #3120506)
#include <fstream>
#include <iomanip>
using namespace std;
ifstream f( "dezastru.in" );
ofstream g( "dezastru.out" );
double dp[ 27 ][ 27 ];
int kkt[ 27 ][ 27 ];
double v[ 27 ];
int n,k;
int main()
{
f >> n >> k;
for( int i = 1; i <= n; i++ )
f >> v[ i ];
for( int i = 0; i <= n; i++ )
kkt[ i ][ 0 ] = dp[ i ][ 0 ] = 1;
for( int i = 1; i <= n; i++ )
{
for( int j = 1; j <= i; j++ )
{
kkt[ i ][ j ] = kkt[ i - 1 ][ j ] + kkt[ i - 1 ][ j - 1 ];
dp[ i ][ j ] = dp[ i - 1 ][ j ] + dp[ i - 1 ][ j - 1 ] * v[ i ];
}
}
g << fixed << setprecision( 6 ) << dp[ n ][ k ] / (double)kkt[ n ][ k ];
return 0;
}