http://www.cnblogs.com/Tunix/p/4354348.html

 #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream> using namespace std; void setIO(const string& s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
template<typename Q> Q read(Q& x) {
static char c, f;
for(f = ; c = getchar(), !isdigit(c); ) if(c == '-') f = ;
for(x = ; isdigit(c); c = getchar()) x = x * + c - '';
if(f) x = -x;
return x;
}
template<typename Q> Q read() {
static Q x; read(x); return x;
} struct LL {
const static int N = , base = ;
int da[N], n; void init(int n) {
this->n = n;
memset(da, , sizeof(da[]) * n);
} void clear_zero() {
while(n && !da[n-]) n--;
} LL operator * (const int &rhs) const {
static LL c;
c.init(n + );
for(int i = ; i < c.n; i++) {
if(i < n) c.da[i] += da[i] * rhs;
c.da[i+] += c.da[i] / base;
c.da[i] %= base;
}
c.clear_zero();
return c;
} void print() const {
if(n == ) putchar('');
else for(int i = n - ; i >= ; i--) {
putchar(da[i] + '');
}
}
}res; const int LIM = , N = ; int mi[LIM+], primes[N], tot;
bool flag[LIM+]; void get_primes(int n) {
for(int i = ; i <= n; i++) {
if(!flag[i]) primes[tot] = i, mi[i] = tot++;
for(int j = ; j < tot; j++) {
int k = primes[j];
if(i * k > n) break;
flag[i * k] = ;
if(i % k == ) break;
}
}
} int num[N]; void add(int x, int sign) {
for(int i = , k; k = primes[i], k * k <= x; i++) {
while(x % k == ) {
num[i] += sign;
x /= k;
}
}
if(x ^ ) num[mi[x]] += sign;
} int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif int n, m;
scanf("%d%d", &n, &m);
get_primes(n + m);
for(int i = n + m; i > m; i--) add(i, );
for(int i = n; i > ; i--) add(i, -);
add(n - m + , ), add(n + , -); res.da[] = res.n = ; for(int i = ; i < tot; i++) {
while(num[i]--) res = res * primes[i];
} res.print(); puts(""); return ;
}

bzoj3907: 网格的更多相关文章

  1. 卡特兰数 BZOJ3907 网格 NOIP2003 栈

    卡特兰数 卡特兰数2 卡特兰数:主要是求排列组合问题 1:括号化矩阵连乘,问多少种方案 2:走方格,不能过对角线,问多少种方案 3:凸边型,划分成三角形 4:1到n的序列进栈,有多少种出栈方案 NOI ...

  2. bzoj3907 网格 & bzoj2822 [AHOI2012]树屋阶梯——卡特兰数+高精度

    题目:bzoj3907:https://www.lydsy.com/JudgeOnline/problem.php?id=3907 bzoj2822:https://www.lydsy.com/Jud ...

  3. BZOJ3907 网格 卡特兰数

    题目描述 某城市的街道呈网格状,左下角坐标为A(0, 0),右上角坐标为B(n, m),其中n >= m. 现在从A(0, 0)点出发,只能沿着街道向正右方或者正上方行走,且不能经过图示中直线左 ...

  4. BZOJ3907网格

    这东西是拿Cat思想搞得组合数学. 首先做这个需要会用网格法或折线法分析Cat的$C_{2n}^n-C_{2n}^{n-1}$是怎么来的. 网格法:假如没有限制,从(0,0)到(n,n)的方案数为$C ...

  5. HZOJ 20190818 NOIP模拟24题解

    T1 字符串: 裸的卡特兰数题,考拉学长讲过的原题,就是bzoj3907网格那题,而且这题更简单,连高精都不用 结论$C_{n+m}^{n}-C_{n+m}^{n+1}$ 考场上10min切掉 #in ...

  6. C#中如何创建PDF网格并插入图片

    这篇文章我将向大家演示如何以编程的方式在PDF文档中创建一个网格,并将图片插入特定的网格中. 网上有一些类似的解决方法,在这里我选择了一个免费版的PDF组件.安装控件后,创建新项目,添加安装目录下的d ...

  7. pcl曲面网格模型的三种显示方式

    pcl网格模型有三种可选的显示模式,分别是面片模式(surface)显示,线框图模式(wireframe)显示,点模式(point)显示.默认为面片模式进行显示.设置函数分别为: void pcl:: ...

  8. 从点云到网格(三)Poisson重建

    Possion重建是Kazhdan等2006年提出的网格重建方法[1].Possion重建的输入是点云及其法向量,输出是三维网格.Poisson有公开的源代码[2].PCL中也有Poisson的实现. ...

  9. 从点云到网格(二)VRIP介绍

    VRIP(Volumetric Range Image Processing),顾名思义,是从深度图重建网格的一种方法.VRIP是Brian Curless和Marc Levoy在1996年提出来的方 ...

随机推荐

  1. BestCoder Round #85 sum

    大晚上的更一道下午的水题吧.(虽然WA了好多次= =,但真实情况是我比较水) 描述 Given a sequence, you're asked whether there exists a cons ...

  2. .net平台下socket异步通讯

    1,首先添加两个windows窗体项目,一个作为服务端server,一个作为客户端Client 2,然后添加服务端代码,添加命名空间,界面上添加TextBox控件 using System.Net; ...

  3. uboot启动linux的过程

    一.概述 linux内核镜像常见到的有两种形式,zImage和uImage.这两种文件的格式稍有差别,所以启动这两种格式的内核镜像也会有所不同.目前,uboot只支持启动uImage类型的镜像,对zI ...

  4. 掌握C++基础

    以下是笔者在ubuntu系统下编译运行通过的一些反应c++基础特性的例子,包括类,结构体,构造函数,析构函数,函数的重载,this指针,类的继承,虚函数,函数的覆盖和隐藏等.(由于格式问题代码中的乱码 ...

  5. 【POJ1275】Cashier Employment

    题目: Description A supermarket in Tehran is open 24 hours a day every day and needs a number of cashi ...

  6. 计算字符串的最长回文子串 :Manacher算法介绍

    转自: http://www.open-open.com/lib/view/open1419150233417.html Manacher算法 在介绍算法之前,首先介绍一下什么是回文串,所谓回文串,简 ...

  7. Remove highlight from document(Aspose Word 删除高亮)

    Thanks for your inquiry. You can do it using DocumentVisitor. Please try using the following code: / ...

  8. cloudera安装hadoop集群和相关服务

    一.软件准备: 1.下载cloudera-manager-installer.bin(安装...-server),cdh4.cm(这是...-agent),另外还有些需要的关联软件下步添加. 2.先建 ...

  9. Static Classes and Static Class Members

    Static Classes and Static Class Members A static class is basically the same as a non-static class, ...

  10. 查看Mysql执行计划

    使用navicat查看mysql执行计划: 打开profile分析工具: 查看是否生效:show variable like ‘%profil%’; 查看进程:show processlist; 选择 ...