题解:

比较水的题目

普通dp其实复杂度还是比较大的

可以任意模数ntt优化。。

但好像没人写。。

代码:

#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define IL inline
#define rep(i,h,t) for (rint i=h;i<=t;i++)
#define dep(i,t,h) for (rint i=t;i>=h;i--)
const int mo=1e9+;
int n,m,f[][];
int main()
{
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
ios::sync_with_stdio(false);
int T;
cin>>T;
while (cin>>n>>m)
{
m++;
/* f[0][0]=1;
rep(i,1,n)
f[1][i]=f[0][i]=1;
rep(i,2,n)
{
rint tmp=min(i,m);
rep(j,1,tmp)
{
rint tmp=0,m1,m2;
rep(k,0,i-1)
{
m1=f[k][j-1]; m2=f[i-k-1][j-1];
if (m1&&m2) tmp=(tmp+1ll*m1*m2)%mo;
}
f[i][j]=tmp;
}
rep(j,min(i,m)+1,max(n,m))
f[i][j]=f[i][j-1];
} */
f[][]=;
rep(i,,n) f[i][]=f[i][]=;
rep(i,,m)
rep(j,,n)
{
rint tmp=;
rep(k,,j-)
{
tmp=(tmp+1ll*f[i-][k]*f[i-][j-k-])%mo;
}
f[i][j]=tmp;
}
cout<<(f[m][n]-f[m-][n]+mo)%mo<<endl;
//cout<<(f[n][m]-f[n][m-1]+mo)%mo<<endl;
}
return ;
}

bzoj3769 spoj 8549 BST again的更多相关文章

  1. 【BZOJ3769】spoj 8549 BST again DP(记忆化搜索?)

    [BZOJ3769]spoj 8549 BST again Description 求有多少棵大小为n的深度为h的二叉树.(树根深度为0:左右子树有别:答案对1000000007取模) Input 第 ...

  2. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  3. 【BZOJ3769】BST again [DP]

    BST again Time Limit: 10 Sec  Memory Limit: 256 MB[Submit][Status][Discuss] Description 求有多少棵大小为n的深度 ...

  4. BZOJ3769:BST again(记忆化搜索DP)

    Description 求有多少棵大小为n的深度为h的二叉树.(树根深度为0:左右子树有别:答案对1000000007取模) Input 第一行一个整数T,表示数据组数. 以下T行,每行2个整数n和h ...

  5. BZOJ 2588: Spoj 10628. Count on a tree [树上主席树]

    2588: Spoj 10628. Count on a tree Time Limit: 12 Sec  Memory Limit: 128 MBSubmit: 5217  Solved: 1233 ...

  6. [LeetCode] Delete Node in a BST 删除二叉搜索树中的节点

    Given a root node reference of a BST and a key, delete the node with the given key in the BST. Retur ...

  7. [LeetCode] Serialize and Deserialize BST 二叉搜索树的序列化和去序列化

    Serialization is the process of converting a data structure or object into a sequence of bits so tha ...

  8. [LeetCode] Largest BST Subtree 最大的二分搜索子树

    Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...

  9. [LeetCode] Inorder Successor in BST 二叉搜索树中的中序后继节点

    Given a binary search tree and a node in it, find the in-order successor of that node in the BST. No ...

随机推荐

  1. 用户 'IIS APPPOOL\xxxx' 登录失败

    一.现象发布到iis后,网站出现以下提示异常详细信息: System.Data.SqlClient.SqlException: 用户 'IIS APPPOOL\IdealTest' 登录失败. 二.分 ...

  2. spring集成cxf实现webservice接口功能

    由于cxf的web项目已经集成了Spring,所以cxf的服务类都是在spring的配置文件中完成的.以下是步骤:第一步:建立一个web项目.第二步:准备所有jar包.将cxf_home\lib项目下 ...

  3. 部署openfaas

    首先必须部署Docker CE 17.05或者以上版本. 首先卸载旧版本, $ sudo yum remove docker \ docker-common \ docker-selinux \ do ...

  4. RS485 通信接收时丢失0x11等数据

    RS485通信接收方,丢弃掉了值为 0x11 的数据. 怀疑 0x11 被转义,没有按照原始数据接收, 查看ASCII码对应表 0x11 代表 “本文结束”, 因此丢弃是有可能的. 要想接收原始数据而 ...

  5. docker拉取镜像报错:net/http: TLS handshake timeout.

    docker拉取镜像报错:net/http: TLS handshake timeout. 启动一个后台的busybox容器 [yunva@node1 network-scripts]$ docker ...

  6. Less常用知识点

    上篇文章介绍了如何安装Less,我们将所有东西都写在.less里面,最后通过命令将.less转换成.css文件,就可以放入到项目里用了.今天了解一些less常用知识点. 1.变量:声明两个变量,一个是 ...

  7. Codeforces 671D Roads in Yusland [树形DP,线段树合并]

    洛谷 Codeforces 这是一个非正解,被正解暴踩,但它还是过了. 思路 首先很容易想到DP. 设\(dp_{x,i}\)表示\(x\)子树全部被覆盖,而且向上恰好延伸到\(dep=i\)的位置, ...

  8. -bash: /opt/cslc/jdk1.8.0_144/bin/jps: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录

    yum install -y  glibc.i686 解决问题

  9. Java调用oracle存储过程通过游标返回临时表数据

    注:本文来源于 <  Java调用oracle存储过程通过游标返回临时表数据   > Java调用oracle存储过程通过游标返回临时表数据 项目开发过程中,不可避免的会用到存储过程返回结 ...

  10. conda 安装多个版本的python

    再添加一个python3.6conda create --name py36 python=3.6然后通过source activate py36来激活环境