zoukankan      html  css  js  c++  java
  • csu 1967 二项式概率

    传送门:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1967

    N最大50,其实不会超int,一开始WA,以为是精度大数溢出什么的问题。在这上面浪费了很多时间。

    忽略了另外一种情况。当n为偶数的时候,如果v2获得了n/2的票,v1无论如何都赢不了,所以在第一个特判出了这个问题,没有特判全。如果没有捕捉到这个点,在下面计算概率不满足情况下,输出的是“

    PATIENCE, EVERYONE!"的情况,错误。

    所以还是要严谨啊。

    #include <iostream>
    #include <string>
    #include <queue>
    #include <map>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <vector>
    #include <queue>
    #define eps 1e-8
    using namespace std;
    typedef long long LL;
    const int MAXN = 502;
    double c[55][55];
    
    void init()
    {
        c[0][0]=c[1][0]=c[1][1]=1;
        for(int i=2;i<=50;i++)
        {
            c[i][0]=c[i][i]=1;
            for(int j=1;j<i;j++)
                c[i][j]=c[i-1][j]+c[i-1][j-1];
        }
    }
    
    int main() {
        init();
        int t;
        scanf("%d", &t);
        while (t--) {
            int n, v1, v2;
            double w;
            scanf("%d%d%d%lf", &n, &v1, &v2, &w);
            int m = n-v1-v2;
            int xu = n/2 ;
            if ((n%2==1&&v2>xu) || (n%2 == 0&&v2>=xu)) {
                printf("RECOUNT!
    ");
                continue;
            }
            if (xu+1 <= v1) {
                printf("GET A CRATE OF CHAMPAGNE FROM THE BASEMENT!
    ");
                continue;
            }
            double k = 0;
            for(int i = xu+1-v1; i <= m; i++) {
                k += c[m][i];
            }
            //cout<< k<<endl;
            for(int i = 0; i < m; i++)
                k /= 2;
            if (k*100 - w >eps) printf("GET A CRATE OF CHAMPAGNE FROM THE BASEMENT!
    ");
            else printf("PATIENCE, EVERYONE!
    ");
        }
        return 0;
    }
  • 相关阅读:
    简单的NHibernate helper类,支持同一事务的批量数据处理
    外部唯一窗体
    Nhibernate常见的错误
    NHB下载地址
    oracle jdbc连接
    linux 中国发行版
    转:pl/sql develop的使用
    Oracle Database 10g Release 2 JDBC Drivers
    转:Setting up a Msysgit Server with copSSH on Windows
    oracle基础学习
  • 原文地址:https://www.cnblogs.com/zhangmingzhao/p/7225820.html
Copyright © 2011-2022 走看看