标签:lin 运算 script print space HERE images namespace ios
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const int N = 100000+100;
ll read() {
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;
}
int a[N],b[N];//0表示& , 1表示 | ,2表示^
double c[N], f[N][40];
int main() {
freopen("exp.in","r",stdin);
freopen("exp.out","w",stdout);
int n = read();
for(int i = 1; i <= n; ++i) a[i] = read();
for(int i = 1; i <= n; ++i) b[i] = read();
for(int i = 1; i <= n; ++i) scanf("%lf",&c[i]);
for(int i = 1; i <= n; ++i) {
for(int j = 0; j <= 30; ++j) {
int k = (b[i] >> j) & 1;
if(a[i] == 0) {
if(k)
f[i][j] = f[i-1][j];
else
f[i][j] = c[i] * f[i-1][j];
}
if(a[i] == 1) {
if(k)
f[i][j] = (1 - c[i]) + c[i] * f[i-1][j];
else
f[i][j] = f[i-1][j];
}
if(a[i] == 2) {
if(k)
f[i][j] = (1 - c[i]) * (1 - f[i-1][j]) + c[i] * f[i-1][j];
else
f[i][j] = f[i-1][j];
}
}
}
int now = 1;
double ans = 0.0;
for(int i = 0; i <= 30; ++i) {
ans += f[n][i] * now;
now <<= 1;
}
printf("%.1lf",ans);
return 0;
}
标签:lin 运算 script print space HERE images namespace ios
原文地址:https://www.cnblogs.com/wxyww/p/9798812.html