zoj[3868]gcd期望】的更多相关文章

题意:求n个数组成的集合的所有非空子集的gcd的期望 大致思路:对于一个数x,设以x为约数的数的个数为cnt[x],所组成的非空集合个数有2^cnt[x]-1个,这其中有一些集合的gcd是x的倍数的,怎么求得最终结果呢?下面来说明过程. 令f[x] = 2^cnt[x]-1,表示以x为gcd的集合个数.令maxn为所有数的最大值,一开始f[maxn]=2^cnt[maxn]-1是肯定正确的.若从大到小更新f数组,类似数学归纳法,f[x]需要减去f[2x].f[3x].....f[px],px<=…
GCD Expectation Time Limit: 4 Seconds                                     Memory Limit: 262144 KB                             Edward has a set of n integers {a1, a2,...,an}. He randomly picks a nonempty subset {x1, x2,…,xm} (each nonempty subset has…
给一个集合,大小为n , 求所有子集的gcd 的期望和 . 期望的定义为 这个子集的最大公约数的K次方 : 每个元素被选中的概率是等可能的 即概率 p = (发生的事件数)/(总的事件数); 总的事件数 = 2^n -1; 大小为n的集合的非空子集个数为2^n -1 期望 = p(i) *i; = 1*p(1) + 2*p(2) + ... +n*p(n); 设x发生的事件数为 dp[x] , 则上式可化简为: =1*dp[1]/(2^n-1) + 2*dp[2]/(2^n-1) + ... +…
GCD Expectation Time Limit: 4 Seconds     Memory Limit: 262144 KB Edward has a set of n integers {a1,a2,...,an}. He randomly picks a nonempty subset {x1,x2,-,xm} (each nonempty subset has equal probability to be picked), and would like to know the ex…
Description Edward has a set of n integers {a1, a2,...,an}. He randomly picks a nonempty subset {x1, x2,…,xm} (each nonempty subset has equal probability to be picked), and would like to know the expectation of [gcd(x1, x2,…,xm)]k. Note that gcd(x1, …
3868 - Earthstone: Easy Version Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3867 Description Earthstone is a famous online card game created by Lizard Entertainment. It is a collectible card g…
Domination Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3822 Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends.…
GCD Reduce Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge You are given a sequence {A1, A2, ..., AN}. You task is to change all the element of the sequence to 1 with the following operations (you may need to apply it multiple ti…
There is a very simple and interesting one-person game. You have 3 dice, namely Die1, Die2 and Die3. Die1 has K1 faces. Die2 has K2 faces. Die3 has K3 faces. All the dice are fair dice, so the probability of rolling each value, 1 to K1, K2, K3 is exa…
题目链接 \(Description\) 有1个吸血鬼和n-1个人,每天有且只会有两个人/吸血鬼相遇,如果是人与吸血鬼相遇,那个人会有p的概率变成吸血鬼:否则什么也不发生.求n个都变成吸血鬼的期望天数. \(Solution\) 我还是写一下吧..期望题一般倒着递推. 设\(f[i]\)为当前有\(i\)个吸血鬼,要变成\(n\)个吸血鬼的期望天数.那么\(f[n]=0\),答案即\(f[1]\). 一天要么变一个要么不变,很好想到: \[f[i]=p_i(f_{i+1}+1)+(1-p_i)(…