HDU_5810:Balls and Boxes(期望)

这题似乎就是纯概率论。。

E(V)=D(X_i)=npq  (p=1/m,p+q=1)

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

LL n,m;
LL gcd(LL a,LL b)
{
    return b?gcd(b,a%b):a;
}

int main()
{
    while(cin>>n>>m && n+m)
    {
        LL a=n*m-n,b=m*m;
        LL g=gcd(a,b);
        cout<<a/g<<‘/‘<<b/g<<endl;
    }
}
时间: 2024-12-12 13:58:30

HDU_5810:Balls and Boxes(期望)的相关文章

hdu-5810 Balls and Boxes(概率期望)

题目链接: Balls and Boxes Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment, he

博客园首页新随笔联系管理订阅 随笔- 524 文章- 0 评论- 20 hdu-5810 Balls and Boxes(概率期望)

Balls and Boxes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 798    Accepted Submission(s): 527 Problem Description Mr. Chopsticks is interested in random phenomena, and he conducts an experi

HDU 5810 Balls and Boxes(盒子与球)

HDU 5810 Balls and Boxes(盒子与球) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Description 题目描述 Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment

hdu 5810 Balls and Boxes 二项分布

Balls and Boxes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 260    Accepted Submission(s): 187 Problem Description Mr. Chopsticks is interested in random phenomena, and he conducts an experi

HDU 5810 Balls and Boxes

n*(m-1)/(m*m) #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue

【HDU 5810多校】Balls and Boxes(打表/数学)

1.打表找规律,下面是打表程序: #include <iostream> #include <cstdio> #define ll long long #define N 100005 using namespace std; ll n,m,b[N],ans,num; ll sqr(ll x) { return x*x; } void dfs(ll r){ if(r==0){ num++; for(int i=1;i<=m;i++) ans+=sqr(b[i]); retur

2015年NEUACM一月月赛

A Money , money 时间限制: 1 Sec  内存限制: 128 MB 提交: 15  解决: 14 [提交][状态][讨论版] 题目描述 Small K seen recently stock market really too violent, so he want to choose some ways to earn money. At every month, he can use three ways to manage his money . For example ,

hdu 5821 Ball (贪心)

Ball Description ZZX has a sequence of boxes numbered 1,2,...,n. Each box can contain at most one ball. You are given the initial configuration of the balls. For 1 \leq i \leq n, if the i-th box is empty then a[i]=0, otherwise the i-th box contains e

hdu 5821 Ball(2016 Multi-University Training Contest 8——贪心+排序)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5821 Ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 515    Accepted Submission(s): 309 Problem Description ZZX has a sequence of boxes numbe