Cod sursa(job #2190821)
Utilizator | Ian David Bocioaca iandavidro | Data | 31 martie 2018 19:32:42 |
---|---|---|---|
Problema | Dezastru | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<fstream>
using namespace std;
ifstream fin("dezastru.in");
ofstream fout("dezastru.out");
int j,n,t,i;
double s,x,dp[40][40];
int main(){
fin>>n>>t;
dp[0][0]=1;
for(i=1;i<=n;++i){
for(j=dp[i][0]=1,f>>x;j<=i;++j){
dp[i][j]=dp[i-1][j]+x*dp[i-1][j-1];
}
}
s=dp[n][t];
for(i=t+1;i<=n;++i){
s/=i;
}
for(i=1;i<=n-t;++i){
s*=i;
}
fout<<s;
return 0;
}