Home  >  Article  >  Web Front-end  >  Codeforces Round #259 (Div. 1)??Little Pony and Expected Maximum_html/css_WEB-ITnose

Codeforces Round #259 (Div. 1)??Little Pony and Expected Maximum_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:00:51976browse

题目连接

  • 题意:
    输入n、m,表示一个n面的色子(面上的值为1-n),投掷m次,求得到的最大值的期望(1?≤?m,?n?≤?105).
  • 分析:
    假设当前得到的最大值是Max,那么对应的概率是:sigma(C(m,k) * ((1 / n) ^ k )*(((Max - 1) / n) ^ (m - k)) ),(1 感叹一下,才发现pow函数和快速幂的效率是一样的。。
  • int main (){    int n, m;    while (~RII(n, m))    {        double ans = 0;        FE(Max, 1, n)        {            ans += Max * (pow((double)Max / n, m) - pow((Max - 1.0) / n, m));        }        printf("%.10f\n", ans);    }    return 0;}


    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn