Cod sursa(job #1324759)

Utilizator cautionPopescu Teodor caution Data 22 ianuarie 2015 19:23:26
Problema Dezastru Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream>
using namespace std;
int main()
{
    ifstream in("dezastru.in");
    ofstream out("dezastru.out");
    short n, k;
    float v[30], f;
    in>>n>>k;
    v[0]=1.0f;
    for(short i=1; i<=n; ++i)
    {
        in>>f;
        for(short j=i; j>0; --j)
            v[j]=((float)j)/i*f*v[j-1]+(((float)i)-j)/i*v[j];
    }
    out<<v[k];
    return 0;
}