# hdu5985[概率dp] 2016青岛icpc现场赛

#include <bits/stdc++.h>
using namespace std;
double rev[12][105];
double p[12][105];
double ans[12];
int a[12];
int T, n;
double fastpow(double a, int b) {
double ret = 1.0;
while (b) {
if (b & 1) {
ret *= a;
}
a = a * a;
b >>= 1;
}
return ret;
}
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%lf", &a[i], &p[i][1]);
}
if (n == 1) {
puts("1.000000");
continue;
}
for (int i = 1; i <= n; i++) {
for (int j = 2; j <= 75; j++) {
p[i][j] = p[i][1] * p[i][j - 1];
}
rev[i][0] = 1.0;
for (int j = 1; j <= 75; j++) {
alldead[i][j] = fastpow(1.0 - p[i][j], a[i]);
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= 72; j++) {
double tmp = 1;
for (int k = 1; k <= n; k++) {
if (k == i) continue;
}
ans[i] += (rev[i][j] - rev[i][j + 1]) * tmp;
}
}
for (int i = 1; i <= n; i++) {
if (i != 1) printf(" ");
printf("%.6f", ans[i]);
ans[i] = 0.0;
} puts("");
}
return 0;
}

posted @ 2017-11-02 19:29 UnderSilence 阅读(...) 评论(...) 编辑 收藏