luogu2473 [SCOI2008]獎勵關
阿新 • • 發佈:2018-01-03
== clas turn include names n) https log namespace
題解參照這裏
每個研究完記得乘一個1/n,這是乘了概率。
#include <iostream>
#include <cstdio>
using namespace std;
double dp[105][33005];
int n, k, p[25], d[25], uu;
int main(){
cin>>k>>n;
for(int i=1; i<=n; i++){
scanf("%d", &p[i]);
scanf("%d", &uu);
while(uu){
d[i] |= 1 <<(uu-1);
scanf("%d", &uu);
}
}
for(int i=k; i>=1; i--)
for(int j=0; j<(1<<n); j++){
for(int l=1; l<=n; l++)
if((j&d[l])==d[l])
dp[i][j] += max(dp[i+1][j], dp[i+1][j|(1<<(l-1))]+p[l]);
else
dp[i][j] += dp[i+1][j];
dp[i][j] /= n;
}
printf("%.6lf\n", dp[1][0]);
return 0;
}
luogu2473 [SCOI2008]獎勵關