poj3440
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
#define pi acos(-1.0)
double m, n, t, c;//坑!!
double calc_2(double m, double n, double t, double c)
{
return (t - c)*c*((m - 1)*(n) +(m) *(n - 1)) + c*c / 2.0*(m + n - 2) * 2;
}
double calc_3()
{
return (m - 1)*(n - 1) * c * c *(1.0 - pi/4);
}
double calc_4()
{
return (m - 1)*(n - 1) * pi * c * c / 4.0;
}
int main()
{
int T;
cin >> T;//一开始竟然两个变量重名了。。
for (int i = 1; i <= T; i++)
{
cin >> m >> n >> t >> c;
cout << "Case " << i << ":" << endl;
double s = m * n * t * t;
cout << "Probability of covering 1 tile = " << fixed << setprecision(4) << (1 - (calc_2(m, n, t, c) + calc_3() + calc_4()) / s) * 100 << "%" << endl;
cout << "Probability of covering 2 tiles = " << fixed << setprecision(4) << calc_2(m, n, t, c) * 100 / s << "%" << endl;
cout << "Probability of covering 3 tiles = " << fixed << setprecision(4) << calc_3() * 100 / s << "%" << endl;
cout << "Probability of covering 4 tiles = " << fixed << setprecision(4) << calc_4() * 100 / s << "%" << endl;
cout << endl;
}
}
补充:软件开发 , C++ ,