zoukankan      html  css  js  c++  java
  • light oj 1317

    Description

    You probably have played the game "Throwing Balls into the Basket". It is a simple game. You have to throw a ball into a basket from a certain distance. One day we (the AIUB ACMMER) were playing the game. But it was slightly different from the main game. In our game we were N people trying to throw balls into M identical Baskets. At each turn we all were selecting a basket and trying to throw a ball into it. After the game we saw exactly S balls were successful. Now you will be given the value of N and M. For each player probability of throwing a ball into any basket successfully is P. Assume that there are infinitely many balls and the probability of choosing a basket by any player is 1/M. If multiple people choose a common basket and throw their ball, you can assume that their balls will not conflict, and the probability remains same for getting inside a basket. You have to find the expected number of balls entered into the baskets after K turns.

    Input

    Input starts with an integer T (≤ 100), denoting the number of test cases.

    Each case starts with a line containing three integers N (1 ≤ N ≤ 16), M (1 ≤ M ≤ 100) and K (0 ≤ K ≤ 100) and a real number P (0 P ≤ 1). P contains at most three places after the decimal point.

    Output

    For each case, print the case number and the expected number of balls. Errors less than 10-6 will be ignored.

    Sample Input

    2

    1 1 1 0.5

    1 1 2 0.5

    Sample Output

    Case 1: 0.5

    Case 2: 1.000000


    题意:
    n个人 m个篮子 每一轮每一个人能够选m个篮子中一个扔球 扔中的概率都是p 求k轮后全部篮子里面球数量的期望值
    思路:
    依据期望 的定义与篮筐个数无关。由于题目如果互不影响。结果就是N*K*P。
    代码:
    #include<cstdio>
    using namespace std;
    int main()
    {
        int T;
        int casex=1;
        double N,M,K,P;
        double ans;
        scanf("%d",&T);
        while(T--)
        {
            scanf("%lf%lf%lf%lf",&N,&M,&K,&P);
            ans=N*K*P;
            printf("Case %d: %lf
    ",casex++,ans);
        }
        return 0;
    }
    

  • 相关阅读:
    只要我跑的够快,内卷它就卷不到我,一名高中生是如何做到在疫情下涨薪70%的?
    一个@Transaction哪里来这么多坑?
    基于netty实现一个完整的TFTP服务器
    DBeaver安装和注意要点
    Logstash将ES服务器A数据迁移ES服务器B
    Logstash迁移ES5.6.1一个索引多type类型迁移到ES7.6.2无type类型
    windows下使用filezilla上传文件权限问题
    logstash7.6.2更新已存在的elasticsearch记录
    mysql磁盘空间不足报错
    Kibana中DevTools命令集锦
  • 原文地址:https://www.cnblogs.com/wzjhoutai/p/7044299.html
Copyright © 2011-2022 走看看