LightOJ 1248 Dice (III)】的更多相关文章

题目链接:LightOJ - 1248 Description Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the dice is fair, that means when you throw the dice, the probability…
题目链接:https://vjudge.net/problem/LightOJ-1248 1248 - Dice (III)    PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see a…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1248 题意:有一个 n 面的骰子,问至少看到所有的面一次的所需 掷骰子 的 次数的期望: 第一个面第一次出现的概率是p1 n/n; 第二个面第一次出现的概率是p2 (n-1)/n; 第三个面第一次出现的概率是p3 (n-2)/n; ... 第 i 个面第一次出现的概率是pi (n-i+1)/n; 先看一下什么是几何分布: 几何分布: 在第n次伯努利试验中,试验 k 次才得到第一次成功…
Description Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the dice is fair, that means when you throw the dice, the probability of occurring any fa…
期望,$dp$. 设$dp[i]$表示当前已经出现过$i$个数字的期望次数.在这种状态下,如果再投一次,会出现两种可能,即出现了$i+1$个数字以及还是$i$个数字. 因此 $dp[i]=dp[i]*i/n+dp[i+1]*(n-i)/n+1$,即$dp[i]=dp[i+1]+n/(n-i)$,$dp[n]=0$,推出$dp[0]$即可. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio…
题意:给出一个n面的色子,问看到每个面的投掷次数期望是多少. 析:这个题很水啊,就是他解释样例解释的太...我鄙视他,,,,, dp[i] 表示 已经看到 i 面的期望是多少,然后两种选择一种是看到新的一面,另一种是看到旧的一面,然后就很出答案了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include &…
学习博客:戳这里 题意:有一个 n 面的骰子,问至少看到所有的面一次的所需 掷骰子 的 次数的期望: 第一个面第一次出现的概率是p1 n/n; 第二个面第一次出现的概率是p2 (n-1)/n; 第三个面第一次出现的概率是p3 (n-2)/n; ... 第 i 个面第一次出现的概率是pi (n-i+1)/n; 先看一下什么是几何分布: 几何分布: 在第n次伯努利试验中,试验 k 次才得到第一次成功的机率为p.详细的说是:前k-1次皆失败,第k次成功的概率为p. 几何分布的期望E(X) = 1/p;…
1248 - Dice (III)   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the di…
G - Dice (III) Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Description Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that…
题意:给你n个面的骰子,问扔出所有面的期望次数. 虽然这题挺简单的但还是要提一下.这题题目给出了解法. E(m)表示得到m个不同面的期望次数. E(m+1)=[((n-m)/n)*E(m)+1]+(m/n)*E(m+1); 想必((n-m)/n)*E(m)+1这个很好理解吧,当得到m个面时他有((n-m)/n)的概率得到没得到过的面 而(m/n)*E(m+1)不太好理解为什么,其实题目已经给出解释了,如果他有(m/n)的概率出到不同 面也有1-(m/n)的概率得到相同面,所以直接加上((n-m)…
设dp_i为已经出现了i面,需要的期望次数,dp_n=0 那么dp_i= i/n*dp_i + (n-i)/n*dp_(i+1) + 1 现在已经i面了,i/n的概率再选择一次i面,(n-i)/n的概率选到新的一面,分别乘其期望次数,并且这次丢过,所以+1 #include<bits/stdc++.h> using namespace std; #define lowbit(x) ((x)&(-x)) typedef long long LL; typedef pair<int,…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1017 搞了一个下午才弄出来,,,,, 还是线性DP做的不够啊 看过数据量就知道状态转移方程和x,没有关系 然后再仔细推导就会知道整个转移方程只和k与y的差值有关 然后继续推导.... 定义dp[i][j]表示表示第j步删除最上边的i点, 定义mv[i]表示删除i点的同时可以向下移动的最远位置(可以预处理出来) 那么dp[i][j]=max(dp[i-1][j],dp[i-mv…
http://www.lightoj.com/volume_showproblem.php?problem=1017 题意:给出刷子的宽和最多横扫次数,问被扫除最多的点是多少个. 思路:状态设计DP[i][j]代表刷子下边界为i已用了j次时最大个数.决策为扫和跳过. /** @Date : 2016-12-18 14:25:51 * @FileName: LightOJ 1017 DP?.cpp * @Platform: Windows * @Author : Lweleth (SoundEar…
1017 - Brush (III)    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Samir returned home from the contest and got angry after seeing his room dusty. Who likes to see a dusty room after a brain storming programming contest?…
1138 - Trailing Zeroes (III) PDF (English) problem=1138" style="color:rgb(79,107,114)">Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1145 题解:首先只要是dp的值只和上一个状态有关系那么就可以优化一维,然后这题不妨设dp[2][M],表示和为1-M的一共有多少种有种前缀的思想. 然后dp[][M]=dp[][M-1]-dp[M-k]. #include <iostream> #include <cstring> #include <cstdio> #define mod 1000…
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> using namespace std; int t,n; double dp[100010]; int main() { scanf("%d",&t); int cas=1; while(t--) { scanf("%d",&n); dp[n]=0…
题目链接 题意: 给一个质地均匀的n的骰子, 求投掷出所有点数至少一次的期望次数. 思路: 这就是一个经典的邮票收集问题(Coupon Collector Problem). 投掷出第一个未出现的点数的概率为n/n = 1, 因为第一次投掷必然是未出现的. 第二个未出现的点数第一次出现的概率为 (n - 1) / n,因为有一个已经投掷出现过. 第i个未出现的点数第一次出现的概率为 (n - i) / i, 这满足几何分布. 其期望E = 1/p 所以期望为n *(1 + 1 / 2 + 1 /…
题意:有一个n面筛子,每次扔一下,每面概率相同,要求扔出n面的期望次数 题解:和第三篇论文里的例题一样,算从第i个到第i+1个的概率是(n-i)/n,n面中找n-i个没有扔到过的,期望是n/(n-i),总的期望就是(1/1+1/2+...+1/n)*n #include<bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define pi acos(-1.0)…
有一个骰子,n个面,问所有面都被摇出的期望. 转自**的博客,  因为概率是(n-k)/n  所以期望次数是1/(前面这个数) #include<cstdio> #include<algorithm> #include<math.h> #include<string.h> using namespace std; int main() { int T; scanf("%d",&T); ; while(T--){ int n; sc…
KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题    //2019.3.18 POJ 2251 Dungeon Master POJ 3278 Catch That Cow  //4.8 POJ 3279 Fliptile POJ 1426 Find The Multiple  //4.8 POJ 3126 Prime Path POJ 3087 Shuffle…
正推不行就逆推! 经典问题:生日悖论 换成其互斥事件:m个人, 每个人生日都不相同的概率 ≤ 0.5 时最小人数. 这就是邮票收集问题的变形:每个邮票至少出现一次的概率 小于等于 0.5 邮票收集问题资料:https://en.wikipedia.org/wiki/Coupon_collector%27s_problem 我们现在面对的是一个n面的骰子, 骰子的每面都是随机出现的, 求问将所有面都被看完所期望的投掷次数(假设只看最上面那一面) 那么, 问题的解就是: H[n] = (1 + 1/…
[kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find The MultiplePOJ 3126 Prime PathPOJ 3087 Shuffle'm UpPOJ 3414 PotsFZU 2150 Fire GameUVA 11624 Fire!POJ 3984 迷宫问题HDU 1241 Oil Deposit…
专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find The MultiplePOJ 3126 Prime PathPOJ 3087 Shuffle'm UpPOJ 3414 PotsFZU 2150 Fire GameUVA 11624 Fire!POJ 3984 迷宫问题HDU 1241 Oil DepositsHDU 1495 非常可乐HDU 26…
http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1138 Description You task is to find minimal natural number N, so t…
Brush (III) LightOJ - 1017 题意:有一些点,每刷一次可以将纵坐标在区间(y1,y1+w)范围内的所有点刷光,y1为任何实数.最多能刷k次,求最多共能刷掉几个点. 先将点按照纵坐标从小到大排序. 显然,横坐标没有任何作用.记p[i]为排序后第i个点的纵坐标. 显然,每一次以某个点的纵坐标为y1来刷,一定不会比以其他的数为y1来刷更差. 记x[i]为以第i个的纵坐标为y1来刷能刷掉的点的数量.容易预处理出来. ans[i][j]表示以第i个的纵坐标为y1,刷j次能刷掉的点数…
Throwing Dice LightOJ - 1064 方法: 设ans[i][j]表示i个骰子点数恰好为j的概率.那么ans[1][1]到ans[1][6]都为1/6. 显然,$ans[i][j]=sum\{ans[i-1][j-k]\}(1<=k<=6,j>k)$ n和x上限很小,直接处理出所有点数恰好为某个值的结果,然后再做一遍类似前缀和的东西处理出所有点数大于等于某个值的结果.这里答案需要分数,于是乱写了一个分数结构体. 分数运算(没有优化的): 初始化空的分数:分子为0,分母…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1138 题意:给你一个数n,然后找个一个最小的数x,使得x!的末尾有n个0:如果没有输出impossible 可以用二分求结果,重点是求一个数的阶乘中末尾含有0的个数,一定和因子5和2的个数有关,因子为2的明显比5多,所以我们只需要求一个数的阶乘的因子中一共有多少个5即可; LL Find(LL x) { LL ans = ; while(x) { ans += x/; x /= ;…
1138 - Trailing Zeroes (III)   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N.…
题目链接:http://lightoj.com/volume_showproblem.php? problem=1138 题意:问 N. 末尾 0 的个数为 Q 个的数是什么? 解法:二分枚举N,由于0是由5×2 出现的,2的个数比5多故计算5的个数就可以. 代码: #include <stdio.h> #include <ctime> #include <math.h> #include <limits.h> #include <complex>…