已知有个市有n人,得了僵尸病的概率是p。你去参加了检测,检查出来是阳性。医生告诉你这次检测,得病的人检测出阳性的概率是r11,没得病的人检测出阳性的概率是r12。然后,为了保险起见,医生给你用了更好的药来检测,这次是阴性,这种药得病的人检测出阳性的概率是r21,没得病的人检测出来是阳性的概率r22。请问,你现在得病的概率是多少
已知有个市有n人,得了僵尸病的概率是p。你去参加了检测,检查出来是阳性。医生告诉你这次检测,得病的人检测出阳性的概率是r11,没得病的人检测出阳性的概率是r12。然后,为了保险起见,医生给你用了更好的药来检测,这次是阴性,这种药得病的人检测出阳性的概率是r21,没得病的人检测出来是阳性的概率r22。请问,你现在得病的概率是多少
每行依次输入n,p,r11,r12,r21,r22
每行输出概率,保留6位小数
1000 0.01 1 1 1 0
0.000000
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
int main()
{
int n;
double p,r1,r2,r3,r4,ans,x1,x2;
while(cin>>n>>p>>r1>>r2>>r3>>r4)
{
x1=r1*p/(r1*p+(1-p)*r2);
ans=x1*(1-r3)/(x1*(1-r3)+(1-x1)*(1-r4));
cout<<fixed<<setprecision(6)<<ans<<endl;
}
return 0;
}
已知有个市有n人,得了僵尸病的概率是p。你去参加了检测,检查出来是阳性。医生告诉你这次检测,得病的人检测出阳性的概率是r11,没得病的人检测出阳性的概率是r12。然后,为了保险起见,医生给你用了更好的药来检测,这次是阴性,这种药得病的人检测出阳性的概率是r21,没得病的人检测出来是阳性的概率r22。请问,你现在得病的概率是多少
每行依次输入n,p,r11,r12,r21,r22
每行输出概率,保留6位小数
1000 0.01 1 1 1 0
0.000000
2015浙工大校赛- Problem I: no2(概率题,贝叶斯公式)
原文地址:http://blog.csdn.net/david_jett/article/details/44751797