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,分母…
C - Throwing Dice Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu LightOJ 1064 uDebug Description n common cubic dice are thrown. What is the probability that the sum of all thrown dice is at least x? Input Input starts wit…
题意:给你n个骰子,求n个骰子的和不小于x的概率. 刚开始想每给一组数就计算一次~~太笨了- -,看了别人的代码,用dp,而且是一次就初始化完成,每次取对应的数据就行了.WA了好多次啊,首先不明白的就是: ;i<=;i++) ;j>=;j--) dp[i][j]+=dp[i][j+]; 这段代码不清楚干什么用的,想清楚没? 刚开始求的dp[i][j]表示的是前 i 个骰子掷出总和为 j 的概率 ,题意让求总和不小于 j 的概率,所以把大于 j 的要加上. 然后输出的又WA了好几次~~ 有概率为…
题目大意: 给你n个骰子, 问点数大于等于x的概率是多少? #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<map> using namespace std; typedef long long L…
第一眼以为是概率DP,我还不会.不过看题目那么短就读读,其实这应该还不是概率DP,只是个水水的DP.. dp[n][s]表示掷n次骰子点数和为s的情况数 dp[0][0]=1 dp[i][j]=∑dp[i-1][j-k] (k∈[1,6] 且 j-k>=0) 要求的概率就是情况数/掷n次骰子的总情况数,掷n次骰子总情况数就是6n. 最后的结果分子分母要互质,而分母的质因子只有2和3,所以只要同除以2和3就能化简. #include<cstdio> using namespace std;…
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单A+B] 1001 Opposite Task  [简单题] 1002 Country Roads[搜索题] 1003 Drunk[判环] 1004 Monkey Banana Problem [基础DP] 1006 Hex-a-bonacci[记忆化搜索] 1008 Fibsieve`s Fantabu…
Problem G: Die Game Life is not easy. Sometimes it is beyond your control. Now, as contestants of ACM ICPC, you might be just tasting the bitter of life. But don't worry! Do not look only on the dark side of life, but look also on the bright side. Li…
  The die is cast  InterGames is a high-tech startup company that specializes in developing technology that allows users to play games over the Internet. A market analysis has alerted them to the fact that games of chance are pretty popular among the…
http://poj.org/problem?id=1481 The Die Is Cast Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 860   Accepted: 358 Description InterGames is a high-tech startup company that specializes in developing technology that allows users to play…
http://www.boost.org/doc/libs/1_61_0/ Boost 1.61.0 Library Documentation Accumulators Framework for incremental calculation, and collection of statistical accumulators. Author(s): Eric Niebler First Release: 1.36.0 Standard: Categories: Math and nume…