hdu 5810:Balls and Boxes(期望)】的更多相关文章

 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, he thr…
Balls and Boxes 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment, he throws n balls into m boxes in such a manner t…
Balls and Boxes 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment, he throws n balls into m boxes in such a manner t…
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…
题目链接 这题似乎就是纯概率论.. 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…
官方题解看不太懂,参考了一些人的博客以后自己证明如下: 其中D(X)和E(X)的公式如下(参考自百度百科): 其中 p = 1 / m .(这是每一个单独事件发生的概率期望,在这里单独事件指的是一个球放到m个盒子里面,放到每个盒子里面的概率都是一样的,所以期望都是1 / m了) 推出了公式以后,代码就很好写了.代码如下: #include <stdio.h> #include <algorithm> #include <string.h> using namespace…
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…
题目链接: 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…
Balls and Boxes                                                                            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)                                                                            …
C. Balls and Boxes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from…
260C - Balls and Boxes 思路:模拟.在x前面找到最小值,如果没有,从0跳到n,继续找到最小值,边找最小值路过的点边减1.然后所有值都减去最小值,最小值那个点加上减去的值. 找到x前面离x最近的最小值的原因:如果如果在x到最小值之间还有最小值,那么这个最小值最后会变成-1. 简单代码: #include<bits/stdc++.h> using namespace std; #define ll long long ; const ll INF=0x7f7f7f7f; ll…
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…
balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 Description There are n balls with m colors. The possibility of that the color of the i-th ball is color j is ai,jai,1+ai,2+...+ai,m. If the number of b…
Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment, he throws n balls into m boxes in such a manner that each ball has equal probability of going to each boxes. After the experiment,…
Problem Description There are n balls with m colors. The possibility of that the color of the i-th ball +ai,+...+ai,m. If the number of balls with the j-th is x, then you should pay x2 as the cost. Please calculate the expectation of the cost. Input…
这题似乎就是纯概率论.. 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(…
Balls Rearrangement 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4611 Description Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbers the boxes from 0 to A-1. To find the balls easily, he puts the ball numbered x into the…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意:从0走到n,每次走之前掷一次筛子,掷出几点就向前走几点,走到大于等于n的地方就停止.但是,有些地方可以连着走,即到达这个地方时可以接着到达以后的某个格子.问停止是掷骰子的期望? 思路: E(i) (i>=n) 全部为0 对于0<i<n E(i)=(E(i+1)+E(i+2)+E(i+3)+E(i+4)+E(i+5)+E(i+6))/6+1 如果i会被传送到j 那么E(i)=E(j…
Abandoned country 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5723 Description An abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since abandoned for a long time, the roads need to be re-built. There are m(m≤1000000) ro…
Balls Rearrangement Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 25    Accepted Submission(s): 8 Problem Description Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbe…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4190 Distributing Ballot Boxes Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1065    Accepted Submission(s): 536 Problem Description Today, bes…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意: 一共有n种卡片.每买一袋零食,有可能赠送一张卡片,也可能没有. 每一种卡片赠送的概率为p[i],问你将n种卡片收集全,要买零食袋数的期望. 题解: 表示状态: dp[state] = expectation state表示哪些卡片已经有了 找出答案: ans = dp[0] 什么都没有时的期望袋数 如何转移: 两种情况,要么得到了一张新的卡片,要么得到了一张已经有的卡片或者啥都没有.…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意: 你在下简化版飞行棋... 棋盘为一个线段,长度为n. 上面有m对传送门,可以直接将你从a[i]传送到b[i]处. 每扔一次骰子,可以向前移动的步数为骰子的点数. 你的初始位置为0.当位置>=n时,游戏结束. 问你扔骰子次数的期望. 题解: 表示状态: dp[i] = rest steps 位置为i时,剩余需要掷骰子次数的期望. 找出答案: ans = dp[0](初始位置) 如何转移:…
http://acm.hdu.edu.cn/showproblem.php?pid=4611 从A中向B中移动和从B中向A中移动的效果是一样的,我们假设从B中向A中移动 而且A>B 我们先求出所有在B[0]上的点移动到A上的分布情况 可以求出花费 当我们要求B[1]上的点移动到A上的分布情况时 相当于B[0]在A上的分布情况水平右移一个单位 由于B[1]点对于B[0]也向后移动了一个单位 所有相对位置没有移动 但是A中有一个地方需要改动 那就是每次A中最后一个位置的点需要移动到A[0]位置(因为…
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意简单,直接用容斥原理即可 AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include <vector> #include &…
http://acm.hdu.edu.cn/showproblem.php?pid=4710 [code]: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; #define N 1000151 ]; ]; ]; ]; ; int lowbit(int i) { return i&-i; } void add(i…
Problem Description   You live in a village but work in another village. You decided to follow the straight path between your house (A) and the working place (B), but there are several rivers you need to cross. Assume B is to the right of A, and all…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4611 题意:给你一个N.A.B,要你求 AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include <vector> #include…
题意是给定一长为 L 的木棒,每次任意切去一部分直到剩余部分的长度不超过 D,求切割次数的期望. 若木棒初始长度不超过 D,则期望是 0.000000: 设切割长度为 X 的木棒切割次数的期望是 F(X). 则 F(X) = F(切割点位置为 0 ~ D) + F(切割点位置为 D ~ X ) + 1:(此处的 +1 是指首次切割产生的次数) 而 F(切割点位置为 0 ~ D ) = 0:(因为已无需再切割) 令下一次切割点的位置为 T, F(切割点位置为 D ~ X ) = 在D~X上积分 (…
Distributing Ballot Boxes Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 756    Accepted Submission(s): 372 Problem Description Today, besides SWERC'11, another important event is taking plac…