题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6574


思路:用古典概型的方法计算俩个区间不想交的概率,再用 1 减去即可。

由于 枚举俩种括号的所有可能出现的情况是不易的 并且我们知道 俩个区间不相交只和左边区间的右端点和右边区间的左端点有关。已知 选区间 满足伯努利实验,是个独立实验。所以我们可以直接设 左边区间 的右端点为 R、右边区间的 左端点为L那么只要 R< L 即可。

所以不相交的概率可以这么求

然后用逆元公式处理下就行了。

附上我们概率论老师的解题方法:

AC代码:

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+;
ll ksm(ll a,ll b){
ll res=;
while(b){
if(b&){
res=res*a%mod;
}
a=a*a%mod;
b>>=;
}
return res;
}
int main()
{
ll n;
while(cin >> n)
{
cout << (n+)*ksm(*n,mod-)%mod << endl;
}
return ;
}

HDU 6574 Rng的更多相关文章

  1. 线段树模板(HDU 6356 Glad You Came)

    题目: HDU 6356 http://acm.hdu.edu.cn/showproblem.php?pid=6356 很裸的线段树 #include<bits/stdc++.h> #de ...

  2. poj和hdu部分基础算法分类及难度排序

    最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...

  3. HDU重现赛之2019CCPC-江西省赛

    本人蒟蒻,5个小时过了5道,看到好几个大佬AK,%%%%%%% http://acm.hdu.edu.cn/contests/contest_show.php?cid=868 先放大佬的题解(不是我写 ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. HTML5: HTML5 新元素

    ylbtech-HTML5: HTML5 新元素 1.返回顶部 1. HTML5 新元素 自1999年以后HTML 4.01 已经改变了很多,今天,在HTML 4.01中的几个已经被废弃,这些元素在H ...

  2. 25. SPI

  3. 力扣算法题—144Binary Tree Preorder Traversal

    Given a binary tree, return the preorder traversal of its nodes' values. Example: Input: [1,null,2,3 ...

  4. leetcode.位运算.136只出现一次的元素-Java

    1. 具体题目 给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次.找出那个只出现了一次的元素. 说明:你的算法应该具有线性时间复杂度. 你可以不使用额外空间来实现吗? 示例 1 ...

  5. FZU 2079 最大获利(线段树+DP)

    Description Sean准备投资一些项目.有n个投资项目,投资第i个项目需要花费Ci元.Sean发现如果投资了某些编号连续的项目就能赚得一定的钱.现在给出m组连续的项目和每组能赚得的钱,请问采 ...

  6. 移动端mintUI mt-datetime-picker 组件使用详解

    <mt-datetime-picker v-model="pickerVisible" //绑定的数据值 ref="pickerData" // 点击触发 ...

  7. MockServer

    基于Flask实现的一个简易Mock平台,使用标准json结构体编写Mock Api https://github.com/yinquanwang/MockServer   Key Features ...

  8. springMVC 框架的xml配置文件的说明

    springMVC框架xml文件配置的说明,直接上代码: 我们介绍四个xml文件配置以及xml内容的理解:application.xml.spring-mvc.xml.pom.xml 和 web.xm ...

  9. ES5新增方法(数组,字符串,对象)

    一.数组方法 迭代(遍历)方法:forEach().map().filter().some().every(): 1. array. forEach(function(value,index,arr) ...

  10. org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported

    最后找到我的问题,springmvc配置文件中没加 <mvc:annotation-driven/> java代码: @RequestMapping(value="/reques ...