poj 3440 Coin Toss

poj 3440 Coin Toss,第1张

poj 3440 Coin Toss
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;const double PI=acos(-1.0),eps=1e-8;int main(){    int T,ca=0;    for(scanf("%d",&T);T;T--)    {        double n,m,t,c,A[5];        scanf("%lf%lf%lf%lf",&n,&m,&t,&c);        A[0]=t*t*n*m;        A[1]=(t-c)*(t-c)*n*m+(c*(t-c)+c*c/4.0)*4+c*(t-c)*(n+m-4);        A[2]=2*c*(t-c)*n*m-c*(t-c)*(n+m)+c*c*(n+m-2);        A[4]=PI*c*c/4*(n-1)*(m-1);        A[3]=A[0]-A[1]-A[2]-A[4];        printf("Case %d:n",++ca);        for(int i=1;i<=4;i++) printf("Probability of covering %d tile%s = %.4lf%%n",i,(i==1)?" ":"s",A[i]/A[0]*100.0+eps);        printf("n");    }    return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/4907362.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存