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. 嵌入式web server——Goahead启用SSL

    前言 之前已经介绍过如何把goahead移植到linux平台,现在再介绍goahead应用SSL的一些关键要点.因为此博文是继承于上一篇关于移植的博文,有不明白的请先回看.移植篇点这里. 移植环境 g ...

  2. python模块学习 hashlib

    一.hashlib概述 涉及加密服务:14. Cryptographic Services 其中 hashlib是涉及安全散列和消息摘要,提供多个不同的加密算法借口,如SHA1.SHA224.SHA2 ...

  3. 在python 中有时候我们用数组

    在python 中有时候我们用数组操作数据可以极大的提升数据的处理效率, 类似于R的向量化操作,是的数据的操作趋于简单化,在python 中是使用numpy模块可以进行数组和矢量计算. 下面来看下简单 ...

  4. ext 金额大写

    //数字转换成大写金额函数 function atoc(numberValue) { numberValue = numberValue.replace(/,/g,''); numberValue = ...

  5. Git关联远程GitHub仓库

    一.本地安装GIT版本控制软件 二.配置Git,设置用户信息 git config --global user.name "jack" git config --global us ...

  6. about python

    函数式编程 λ演算 LISP,Erlang 尾递归 栈的使用 避免防御式编程 ER实体Entity关系relationship OOP [OOA/D] 属性.行为 继承.聚合.关联 抽象.封装 笛卡尔 ...

  7. 练习2 F题 - 平方和与立方和

      Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description 给定一 ...

  8. 转:靠谱的代码和DRY

    http://www.cppblog.com/vczh/archive/2014/07/15/207658.html 靠谱的代码和DRY 上次有人来要求我写一篇文章谈谈什么代码才是好代码,是谁我已经忘 ...

  9. js共享onload事件

    问题:通过js进行事件绑定,必须在HTML文档加载完成后再执行js脚本,否则可能因DOM不完整导致无法完成预计的效果,但对于不同的需求如何选用最佳的实现方式呢,这里做了整理,可以做参考. 一.对于小型 ...

  10. 对Gearman中client,worker,jobserver的理解

    在gearman的官网http://gearman.org/有以下的一段说明 A Gearman powered application consists of three parts: a clie ...