这题主要是推导数学公式!!!
将概率问题转化为圆心所在的面积!
代码如下:
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<cstring>
#define pi acos(-1.0)
using namespace std;
int main()
{
int i=,k;
double a1,a2,a3,a4,sum,r,m,n,t,c;
cin>>k;
while(k--){
cin>>m>>n>>t>>c;
r=c/2.0;
sum=m*n*t*t;
a2=c*((t-c)*n+c)*(m-)+c*((t-c)*m+c)*(n-);
a3=(c*c-pi*r*r)*(m-)*(n-);
a4=pi*r*r*(m-)*(n-);
a1=sum-a2-a3-a4;
printf("Case %d:\n",++i);
printf("Probability of covering 1 tile = %.4f%%\n",*a1/sum);
printf("Probability of covering 2 tiles = %.4f%%\n",*a2/sum);
printf("Probability of covering 3 tiles = %.4f%%\n",*a3/sum);
printf("Probability of covering 4 tiles = %.4f%%\n",*a4/sum);
printf("\n");
}
}