Cod sursa(job #3327650)
| Utilizator | Data | 4 decembrie 2025 17:58:05 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream f("dezastru.in");
ofstream g("dezastru.out");
int N, K, x[26], cnt;
double prob, v[26];
void backt(int k, double p)
{
if(k > K)
{
cnt++;
prob += p;
}
else
for(int i = x[k - 1] + 1; i <= N; i++)
{
x[k] = i;
backt(k + 1, p * v[i]);
}
}
int main()
{
f >> N >> K;
for(int i = 1; i <= N; i++)
f >> v[i];
backt(1, 1);
g << prob / cnt;
f.close();
g.close();
return 0;
}
