bzoj3769 spoj 8549 BST again
题解:
比较水的题目
普通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的更多相关文章
- 【BZOJ3769】spoj 8549 BST again DP(记忆化搜索?)
[BZOJ3769]spoj 8549 BST again Description 求有多少棵大小为n的深度为h的二叉树.(树根深度为0:左右子树有别:答案对1000000007取模) Input 第 ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- 【BZOJ3769】BST again [DP]
BST again Time Limit: 10 Sec Memory Limit: 256 MB[Submit][Status][Discuss] Description 求有多少棵大小为n的深度 ...
- BZOJ3769:BST again(记忆化搜索DP)
Description 求有多少棵大小为n的深度为h的二叉树.(树根深度为0:左右子树有别:答案对1000000007取模) Input 第一行一个整数T,表示数据组数. 以下T行,每行2个整数n和h ...
- 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 ...
- [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 ...
- [LeetCode] Serialize and Deserialize BST 二叉搜索树的序列化和去序列化
Serialization is the process of converting a data structure or object into a sequence of bits so tha ...
- [LeetCode] Largest BST Subtree 最大的二分搜索子树
Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...
- [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 ...
随机推荐
- DALSA相机开发--修改参数
DALSA gige相机有两种方式可以获取到相机相关参数,一个是读取相机里面的xml文件:另外一个是读取相对应的寄存器的值. 对于修改寄存器的值,有两个相应的函数: 1)GevSetFeatureVa ...
- Golang 类型转换,断言和显式强制转换
1 前言 类型转换,可以用断言(只能使用在interface{}类型转换成其它类型)和显式类型强制转换(常规是用于基本类型) 2 代码 //graphql-go func(params graphql ...
- grep,find
grep是强大的文本搜索工具,他可以对文件逐行查看,如果找到匹配的模式,就可以打印出包含次模式的所有行,并且支持正则表达式 find查找文件的grep是来查找字符串的,文件的内容 grep 文件的内容 ...
- 31)django-序列化
目录 1)序列化 2)为什么不用json序列化 3)django序列化QuerySet,ErrorDict数据 一:序列化 序列化是将对象状态转换为可保持或传输的格式的过程 反序列化是指将存储在存储媒 ...
- python-模块入门
一.模块介绍 模块:模块就是一系列功能的集合体 模块有三种来源: 1.内置模块 2.第三方的模块 3.自定义模块 模块的格式: 1使用python编写的.py文件 2.已被编译为共享库或D ...
- 安装elasticsearch 5.x, 6.x 常见问题(坑)的解决
本人在elasticsearch 5.x, 6.x 安装过程中遇到了一些问题: 警告提示 [2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] una ...
- js跳转页面(转)
<span id="tiao">3</span><a href="javascript:countDown"></a& ...
- 在DOS中操作MySQL数据库出现中文乱码
1. 问题:最近使用到MySQL数据库操作,在DOS下使用命令行向mysql中插入/读取中文时出现乱码问题. 2. 原因:由于CMD客户端默认编码为GBK,而本人在安装MySQL时设置编码为UTF-8 ...
- Confluence 6 查看站点状态
请注意,有关站点的活动信息在默认情况下是禁用的.请查看下面的说明. 如果这个插件被启用的话,有关站点的全局活动状态将会在你的 Confluence 站点中显示出来.显示的数据包括: 在给定的时间内有多 ...
- LeetCode(71):简化路径
Medium! 题目描述: 给定一个文档 (Unix-style) 的完全路径,请进行路径简化. 例如,path = "/home/", => "/home&quo ...