题解:

比较水的题目

普通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. Switch 中参数的范围探讨

    switch 语句必须遵循下面的规则: switch 语句中的 expression 必须是一个整型或枚举类型,或者是一个 class 类型,其中 class 有一个单一的转换函数将其转换为整型或枚举 ...

  2. ffmpeg-201701[10,16,21,23,25]-bin.7z

    ESC 退出 0 进度条开关 1 屏幕原始大小 2 屏幕1/2大小 3 屏幕1/3大小 4 屏幕1/4大小 5 屏幕横向放大 20 像素 6 屏幕横向缩小 20 像素 S 下一帧 [ -2秒 ] +2 ...

  3. daemon.debug hostapd: wlan0: WPA rekeying GTK

    现象描述:client连接上AP后,切换接口(譬如lan口的)模式,静态地址和dhcp模式切换后,一段时间后断开连接,再也连接不上,ap侧日志如下: Wed Nov  8 14:39:31 2017 ...

  4. Mac 上卸载 Java

    如何在 Mac 上卸载 Java? 本文适用于: 平台: Macintosh OS X Java 版本: 7.0, 8.0 使用终端卸载 Oracle Java 注:要卸载 Java,必须具有管理员权 ...

  5. 20)django-session使用

    一:目录 1)session原理 2)cookie与session对比 3)session配置 4)session使用 5)示例 二:session原理 Django的Session机制会向请求的浏览 ...

  6. iOS 去除高德地图下方的 logo 图标

    [self.mapView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, ...

  7. 在Ubuntu 15下搭建V/P/N服务器pptpd安装和配置

    在Ubuntu 15下搭建VPN服务器pptpd安装和配置 在ubuntu下配置vpn的方式有很多种,其中比较常见的是pptpd,它配置简单,但是安全性不高,不过对于一般使用来说足够了,我按照程搭建了 ...

  8. Confluence 6 查看索引和提示

    查看索引 Confluence 使用被称为 Lucene 的搜索引擎.如果你希望在你的 Confluence站点中查看更多有关索引的细节,你可以下载并且运行 Luke.Luke 是一个开发和诊断工具, ...

  9. 【Linux】安装多个JDK并切换

    一.JDK安装1.将安装包jdk-8u111-linux-x64.tar.gz拷贝到安装目录(如/usr/java)下.2.添加可执行权限chmod +x jdk-8u111-linux-x64.ta ...

  10. day 08字符编码 文件处理

    字符编码1.软件启动流程(打开notepad++文档)从硬盘将软件加载到内存上加载test.txt到内存中执行notepad++的代码,将test.txt打到屏幕上 python解释器也是一个应用软件 ...