uva10491 - Cows and Cars(牛和车)

大水题,,,,

ans = ncow/(ncow+ncar)  *  ncar/(ncow+ncar-nshow-1)   +   ncar/(ncow+ncar)  *  (ncar-1)/(ncow+ncar-nshow-1);

代码如下:

#include <cstdio>
#include <cmath>

int main ()
{
    int car, cow, show;
    while(~scanf("%d%d%d",&cow,&car,&show))
    {
        int n = cow+car;
        double ans = 1.0*cow*car/(n*(n-show-1));
        ans+=1.0*car*(car-1)/(n*(n-show-1));
        printf("%.5lf\n",ans);
    }
    return 0;
}



posted on 2013-05-19 21:49  Primo...  阅读(123)  评论(0编辑  收藏  举报