题目分析:

我们思考正好被k个区间覆盖的情况,那么当前这个子段是不是把所有的点分成了两个部分,那么在两个部分之间相互连k条线,再对于剩下的分别连线就很好了?这个东西不难用组合数写出来。

然后我们要证明每个区间的期望长度是点数加一分之一,这个很容易,归纳法证明就行了。

代码:

 #include<bits/stdc++.h>
using namespace std; const int mod = ; int n,k,l;
int f[];
int fac[],inv[],pw[]; int C(int nn,int kk){
return 1ll*fac[nn]*inv[kk]%mod*inv[nn-kk]%mod;
}
int A(int nn,int kk){
return 1ll*fac[nn]*inv[nn-kk]%mod;
} int fast_pow(int now,int pw){
int ans = ,dt = now,bit = ;
while(bit <= pw){
if(bit & pw){ans = 1ll*ans*dt%mod;}
dt = 1ll*dt*dt%mod; bit<<=;
}
return ans;
} int work(int rm){
int ll = ,r = *n;int Rp = fast_pow(f[*n],mod-);
int ans = ;
while(r>=){
int now = C(ll,rm),im = A(r,rm);
int res = 1ll*now*im%mod*f[ll-rm]%mod*f[r-rm]%mod*pw[rm]%mod;
res = 1ll*res*Rp%mod;
ans += res; ans%=mod;
ll++; r--;
}
ans = 1ll*ans*fast_pow(*n+,mod-)%mod*l%mod;
return ans;
} int main(){
scanf("%d%d%d",&n,&k,&l);
f[] = ;fac[] = ;pw[] = ;
for(int i=;i<=*n;i++) pw[i] = *pw[i-]%mod,fac[i] = 1ll*fac[i-]*i%mod;
for(int i=;i<=*n;i++){
f[i] = 2ll*f[i-]%mod*(i-)%mod;
}
inv[*n] = fast_pow(fac[*n],mod-);
for(int i=*n-;i>=;i--) inv[i] = 1ll*inv[i+]*(i+)%mod;
int ans = ;
for(int i=k;i<=n;i++) ans += work(i),ans%=mod;
printf("%d\n",ans);
return ;
}

Codeforces1153F Serval and Bonus Problem 【组合数】的更多相关文章

  1. CF1153F Serval and Bonus Problem

    Serval and Bonus Problem 1.转化为l=1,最后乘上l 2.对于一个方案,就是随便选择一个点,选在合法区间内的概率 3.对于本质相同的所有方案考虑在一起,贡献就是合法区间个数/ ...

  2. CF1153F Serval and Bonus Problem FFT

    CF1153F Serval and Bonus Problem 官方的解法是\(O(n ^ 2)\)的,这里给出一个\(O(n \log n)\)的做法. 首先对于长度为\(l\)的线段,显然它的答 ...

  3. CF1153 F. Serval and Bonus Problem(dp)

    题意 一个长为 \(l\) 的线段,每次等概率选择线段上两个点,共选出 \(n\) 条线段,求至少被 \(k\) 条线段覆盖的长度期望. 数据范围 \(1 \le k \le n \le 2000, ...

  4. Codeforces 1153F Serval and Bonus Problem [积分,期望]

    Codeforces 思路 去他的DP,暴力积分多好-- 首先发现\(l\)没有用,所以不管它. 然后考虑期望的线性性,可以知道答案就是 \[ \int_0^1 \left[ \sum_{i=k}^n ...

  5. Codeforces Round #551 (Div. 2) F. Serval and Bonus Problem (DP/FFT)

    yyb大佬的博客 这线段期望好神啊... 还有O(nlogn)FFTO(nlogn)FFTO(nlogn)FFT的做法 Freopen大佬的博客 本蒟蒻只会O(n2)O(n^2)O(n2) CODE ...

  6. CF1153F Serval and Bonus Problem 【期望】

    题目链接:洛谷 作为一只沉迷数学多年的蒟蒻OIer,在推柿子和dp之间肯定要选推柿子的! 首先假设线段长度为1,最后答案乘上$l$即可. 对于$x$这个位置,被区间覆盖的概率是$2x(1-x)$(线段 ...

  7. @codeforces - 1153F@ Serval and Bonus Problem

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 从一条长度为 l 的线段中随机选择 n 条线段,共 2*n 个线 ...

  8. (light oj 1102) Problem Makes Problem (组合数 + 乘法逆元)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1102 As I am fond of making easier problems, ...

  9. Codeforces Round #551 (Div. 2) EF Solution

    E. Serval and Snake 对于一个矩形,如果蛇的一条边与它相交,就意味着这条蛇从矩形内穿到矩形外,或者从矩形外穿到矩形内.所以如果某个矩形的答案为偶数,意味着蛇的头尾在矩形的同一侧(内或 ...

随机推荐

  1. SAMBA服务和FTP服务讲解(week3_day1)--技术流ken

    samba服务 Smb主要作为网络通信协议; Smb是基于cs架构: 完成Linux与windows之间的共享:linux与linux之间共享用NFS 第一步:安装samba [root@ken ~] ...

  2. Spring Boot 2.x基础教程:快速入门

    简介 在您第1次接触和学习Spring框架的时候,是否因为其繁杂的配置而退却了?在你第n次使用Spring框架的时候,是否觉得一堆反复黏贴的配置有一些厌烦?那么您就不妨来试试使用Spring Boot ...

  3. TensorRT学习总结

    TensorRT是什么 建议先看看这篇https://zhuanlan.zhihu.com/p/35657027 深度学习 训练 部署 平常自学深度学习的时候关注的更多是训练的部分,即得到一个模型.而 ...

  4. .net core identity集成微信授权登录

    最快的方式是直接nuget安装AspNetCore.Authentication.WeChat包. 想要知道是如何实现的,可以看下面github上面的源码. 源码在这里:https://github. ...

  5. flex 圣杯布局

    基本思路 圣杯布局分为3段:上.中.下.  中段被分为:左.中.右3块. 1:采用flex布局时,先把弹性容器主轴设置为垂直方向(flex-direction:column) 2:上.中.下3块弹性项 ...

  6. 【AO笔记】关于创建IFeatureClass中的参考系设置——不能为null也不能为IUnknownCoodinateSystem

    创建一个要素类是很简单的,只需要获取一枚IFeatureWorkspace或者一个IFeatureDataset,然后调用其CreateFeatureClass()即可. 这个CreateFeatur ...

  7. 学习RenderScript,以此来修改LiveWallpaper

    先留个坑,花5天的时间来填满.

  8. android添加阴影

    android底部增加背景 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns: ...

  9. git开发常用命令

    1.基本命令git branch 查看本地分支git branch -r 查看远程分支git checkout xxx 切换分支git pull origin master //从远程同步到本地,ma ...

  10. 解决Editor.md通过代码块原样输出Emoji被强制解析问题

    Editor.md是一款优秀的开源Markdown 编辑器,在使用中遇到的一些问题和功能改进分享给需要的伙伴. 项目地址 https://github.com/pandao/editor.md 问题 ...