1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| #include<bits/stdc++.h> #include<algorithm> #define rep(i,a,n) for(int i=a;i<n;++i) #define per(i,a,n) for(int i=n-a;i>=a;--i) #define fi first #define se second #define cl(x,a) memset(x,a,sizeof(x)) #define all(x) x.begin(),x.end() #define INF 0x3f3f3f3f #define EPS 1e-9 #define mod 1000000007 #define FF 150 using namespace std; const int maxn=1e3+5; const int maxm=1e5+5;
typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int,int> pii;
int t,n,m; int num[maxn]; double p[maxn];
double dead[maxn][FF]; double alive[maxn][FF]; double ans[maxn]; double qpow(double a,int x){ double ans=1.0; while(x){ if(x&1) ans *=a; a*=a; x>>=1;
} return ans; } void solve(){ rep(i,1,n+1){ rep(j,1,FF){ double temp=qpow(p[i],j); dead[i][j]=qpow((1.0-temp),num[i]); alive[i][j]=1.0-dead[i][j]; } } } int main(){ ios::sync_with_stdio(false); cin>>t; while(t--){ cin>>n; rep(i,1,n+1){ cin>>num[i]>>p[i]; } if(n==1){ cout<<fixed<<setprecision(6)<<1.0<<endl; continue; } memset(alive,0,sizeof(alive)); memset(dead,0,sizeof(dead));
solve(); rep(i,1,n+1){ ans[i]=0; rep(j,1,FF){ double temp=1.0; rep(k,1,n+1){ if(i==k) continue; else{ temp*=dead[k][j]; } } ans[i]+=temp*(alive[i][j]-alive[i][j+1]); } } cout<<fixed<<setprecision(6)<<ans[1]; rep(i,2,n+1){ cout<<" "<<fixed<<setprecision(6)<<ans[i]; } cout<<endl; } }
|