深切感觉自己的智商不够用。。TUTTUT 表示自己连题目是什么意思都搞不明白。。
题意我就不多说了吧。。
一共有几种情况,虎虎、鹿虎、鹿鹿、人虎、人鹿。所以只有人想要生存下来,必须所有的虎同归于尽,老虎必须是奇数。
剩下就是求老虎同归于尽的概率了。
每天出现两个生物。 所以每天两只老虎相遇的情况为(t-1)*t 种,所有的情况为t*(t+1)种。
概率p = (t-1)/(t+1) ;
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
int Case = 0;
while(t--)
{
Case++;
int n,m;
scanf("%d%d",&n,&m);
if(n==0)
{
printf("Case %d: %.7f\n",Case,1.0);
continue;
}
else if(n%2==1)
{
printf("Case %d: %.7f\n",Case,0.0);
continue;
}
else
{
double ans=1;
double nn=(double)n;
double mm=(double)m;
while(nn)
{
ans*=(nn-1)/(nn+1);
nn-=2;
}
printf("Case %d: %.7f\n",Case,ans);
}
}
return 0;
}