比较水的概率题;写出公式即可
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
double x,y,p,q;
scanf("%lf%lf%lf%lf",&x,&y,&p,&q);
double tmp1=((1-q)+1.0*q*p*(1-p))*x;
tmp1+=1.0*q*(1-p)*p*y;
tmp1+=1.0*q*p*p*(x+y);
double tmp2=(1-q)*(1-p)*p*x;
tmp2+=(q+(1-q)*p*(1-p))*y;
tmp2+=(1-q)*p*p*(x+y);
if(tmp1>tmp2)
{
printf("tiger %.4lf\n",tmp1);
}
else
printf("wolf %.4lf\n",tmp2);
}
return 0;
}
时间: 2024-11-09 01:53:06