Luogu1641 SCOI2010生成字符串(组合数学)
NOI2018冒泡排序的一个子问题。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define P 20100403
#define N 2000010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n,m,fac[N],inv[N];
int C(int n,int m){return 1ll*fac[n]*inv[m]%P*inv[n-m]%P;}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1641.in","r",stdin);
freopen("1641.out","w",stdout);
const char LL[]="%I64d\n";
#else
const char LL[]="%lld\n";
#endif
n=read(),m=read();
fac[]=;for (int i=;i<=n+m;i++) fac[i]=1ll*fac[i-]*i%P;
inv[]=inv[]=;for (int i=;i<=n+m;i++) inv[i]=P-1ll*(P/i)*inv[P%i]%P;
for (int i=;i<=n+m;i++) inv[i]=1ll*inv[i-]*inv[i]%P;
cout<<(C(n+m,m)-C(n+m,m-)+P)%P;
return ;
}
Luogu1641 SCOI2010生成字符串(组合数学)的更多相关文章
- Luogu P1641 [SCOI2010]生成字符串 组合数学
神仙.... 当时以为是,$x$代表$1$,$y$代表$0$,所以不能过$y=x$的路径数...结果不会... 然后康题解...ヾ(。`Д´。)竟然向右上是$1$,向右下是$0$.... 所以现在就是 ...
- [SCOI2010]生成字符串 题解(卡特兰数的扩展)
[SCOI2010]生成字符串 Description lxhgww最近接到了一个生成字符串的任务,任务需要他把n个1和m个0组成字符串,但是任务还要求在组成的字符串中,在任意的前k个字符中,1的个数 ...
- P1641 [SCOI2010]生成字符串
P1641 [SCOI2010]生成字符串 题目描述 lxhgww最近接到了一个生成字符串的任务,任务需要他把n个1和m个0组成字符串,但是任务还要求在组成的字符串中,在任意的前k个字符中,1的个数不 ...
- 卡特兰数 洛谷P1641 [SCOI2010]生成字符串
卡特兰数 参考博客 介绍 卡特兰数为组合数学中的一种特殊数列,用于解决一类特殊问题 设\(f(n)\)为卡特兰数的第n项 其通项公式为 \[f(n)=\frac{2n\choose n}{n+1} \ ...
- [SCOI2010]生成字符串
题目描述 lxhgww最近接到了一个生成字符串的任务,任务需要他把n个1和m个0组成字符串,但是任务还要求在组成的字符串中,在任意的前k个字符中,1的个数不能少于0的个数.现在lxhgww想要知道满足 ...
- BZOJ1856 [SCOI2010]生成字符串 【组合数】
题目 lxhgww最近接到了一个生成字符串的任务,任务需要他把n个1和m个0组成字符串,但是任务还要求在组成的字符串中,在任意的前k个字符中,1的个数不能少于0的个数.现在lxhgww想要知道满足要求 ...
- BZOJ1856或洛谷1641 [SCOI2010]生成字符串
BZOJ原题链接 洛谷原题链接 可以将\(1\)和\(0\)的个数和看成是\(x\)轴坐标,个数差看成\(y\)轴坐标. 向右上角走,即\(x\)轴坐标\(+1\),\(y\)轴坐标\(+1\),表示 ...
- Luogu 1641[SCOI2010]生成字符串 - 卡特兰数
Description 有$N$ 个 $1$ 和 $M$ 个 $0$ 组成的字符串, 满足前 $k$ 个字符中 $1$ 的个数不少于 $0$ 的个数. 求这样字符串的个数. $1<=M < ...
- 【[SCOI2010]生成字符串】
\(n=m\)时候经典的卡特兰 那\(n!=m\)呢,还是按照卡特兰的方式来推 首先总情况数就是\(\binom{n+m}{n}\),在\(n+m\)个里选择\(n\)个\(1\) 显然有不合法的情况 ...
随机推荐
- cloudstack 创建虚拟机失败
Trying to find a potenial host and associated storage pools from the suitable host/pool lists for th ...
- Nginx 服务器的安装部署(CentOS系统)
1.准备安装环境yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel open openssl-develgcc编译器 ...
- ubuntu 下 go 语言调试器 dlv 的安装
1. 从 https://github.com/derekparker/delve.git 下载delve压缩包delve-master.zip. 2. 使用 winscp 工具将delve-mas ...
- IHttpModule不起作用的两个原因
最近在将系统改造成微服务的过程中,需要对以前的Url请求做兼容性处理,于是就采用了HttpModules模型,但在测试中碰到IHttpModules模块不起作用. 一.IIS配置问题 我用的IIS7. ...
- [GitHub]GitHub for Windows离线安装的方法
这几天一直在尝试安装GitHub for windows ,安装程序是从https://windows.github.com/ 下载到的OneClick 部署程序,版本号为2.11.0.5.可能是因为 ...
- Eclipse中JBoss插件配置
JBoss 服务器集成到Eclispe(考虑Eclipse版本Version: Indigo Service Release 2) http://www.cnblogs.com/sunddenly/p ...
- 51nod 小朋友的笑话
链接 分析: 每次操作把以前没有出现这个数的设为1,有这个数的设为0.首先将当前区间设为1,考虑有set维护这个颜色出现的区间,然后把所有与当前区间相交的拿出来,修改为0. 复杂度?每次操作的线段只会 ...
- Flask学习-Wsgiref库
一.前言 前面在Flask学习-Flask基础之WSGI中提到了WerkZeug,我们知道,WerkZeug是一个支持WSGI协议的Server,其实还有很多其他支持WSGI协议的Server.htt ...
- LeetCode Search for a Range (二分查找)
题意 Given a sorted array of integers, find the starting and ending position of a given target value. ...
- Excel读取Word Table元素
Option Explicit Sub Mian() Application.ScreenUpdating = False Application.DisplayAlerts = False Appl ...