poj 3440 Coin Toss 夜

http://poj.org/problem?id=3440

简单题目 但是由于忽视了int越界 贡献了一次wa

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<cmath>
#define LL long long

using namespace std;
const double PI=acos(-1.0);
int main()
{
   int T;
   double sum,s1,s2,s3,s4;
   scanf("%d",&T);
   for(int w=1;w<=T;++w)
   {
       double n,m,l,d;
       cin>>n>>m>>l>>d;
       sum=n*m*l*l;
       s1=1.0*n*m*(l-d)*(l-d);
       s4=1.0*(n-1)*(m-1)*PI*(1.0*d/2)*(1.0*d/2);
       s2=(1.0*(n-1)*m*l+1.0*(m-1)*n*l)*d-2.0*(n-1)*(m-1)*d*d;
       s3=(n-1)*(m-1)*d*d-s4;
       s1=sum-s2-s3-s4;
       printf("Case %d:\n",w);
       printf("Probability of covering 1 tile  = %.4f%%\n",100.0*s1/sum);
       printf("Probability of covering 2 tiles = %.4f%%\n",100.0*s2/sum);
       printf("Probability of covering 3 tiles = %.4f%%\n",100.0*s3/sum);
       printf("Probability of covering 4 tiles = %.4f%%\n",100.0*s4/sum);
       if(w!=T)
       printf("\n");
   }
   return 0;
}

  

原文地址:https://www.cnblogs.com/liulangye/p/2610669.html