Cod sursa(job #1040784)

Utilizator andy1496Casu-Pop Andrei andy1496 Data 24 noiembrie 2013 22:08:01
Problema Dezastru Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <cstdio>
#include <string.h>

using namespace std;

int i,j,nr,n,k;
double s, p, v[26], a[26][26], b[26][26];
int main(){
	
	freopen ("dezastru.in", "r", stdin);
	freopen ("dezastru.out", "w", stdout);
	
	scanf ("%d %d", &n, &k);
	
    for(i=1;i<=n;i++)
    
        scanf ("%lf", &v[i]);
        
        p=1;
        
        a[0][0]=1;
        b[0][0]=1;
        
    for (i=1;i<=n;i++){
    	
        a[i][0]=1;
        
        b[i][0]=1;
        
        for (j=1;j<=k;j++){
        	
            a[i][j]=a[i-1][j-1]+a[i-1][j];
            
            b[i][j]=b[i - 1][j] + b[i - 1][j - 1]*v[i];
            
        }
    }
    
    printf ("%.*lf", 6, b[n][k]/a[n][k]);
    
    return 0;
}