# solution

$f[i][j]$表示第$i$次操作后手上数字为$j$的概率。

# code

/*
* @Author: wxyww
* @Date:   2020-04-26 08:51:04
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
using namespace std;
typedef long long ll;
const int N = 1 << 21;
ll x = 0,f = 1;char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1; c = getchar();
}
while(c >= '0' && c <= '9') {
x = x * 10 + c - '0'; c = getchar();
}
return x * f;
}
double a[N];
int main() {
for(int i = 0;i < (1 << n);++i)
scanf("%lf",&a[i]);

for(int i = 0;i < n;++i)
for(int j = 0;j < (1 << n);++j)
if(!((j >> i) & 1))
a[j | (1 << i)] += a[j];

for(int i = 0;i < (1 << n);++i) {
if(a[i] - 1 >= -1e-8) {
if(i == (1 << n) - 1) a[i] = 0;
else {puts("INF");return 0;}
}
else a[i] = 1 / (a[i] - 1);
}
for(int i = 0;i < n;++i)
for(int j = 0;j < (1 << n);++j)
if(!((j >> i) & 1))
a[j | (1 << i)] -= a[j];
printf("%.10lf\n",a[(1 << n) - 1]);
return 0;
}

/*
2
0.25 0.25 0.25 0.25

*/
posted @ 2020-04-26 10:38  wxyww  阅读(...)  评论(...编辑  收藏