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 ...
随机推荐
- Ubuntu14下nginx服务器链接PHP
报错:nginx下无法打开php,报错[error] 5040#0: *1 connect() failed (111: Connection ref ... server { listen ; #l ...
- SharePoint 2013: Workflow Manager Backend 服务意外地终止
一.环境:SharePoint 2013 + Workflow Manager 1.0 二.错误描述: Workflow Manager Backend 服务意外地终止,这种情况已经出现了 42106 ...
- HDU 5377 (Exgcd + 原根)
转载自:大牛 知道一个定理了 a ^ x = y (mod p) ===>> logd(a) * x = logd(y) (mod O(p) ) d 为 p 的 原根, O ...
- javascript移动端禁止页面滑动的解决方案
1 前言 移动端网页,发现ios平台的iphone或者ipad,网页可以上下左右移动,而Android版则不会.仅作为记录使用. 2 代码 var mo=function(e){e.preventDe ...
- python创建tcp服务端和客户端
1.tcp服务端server from socket import * from time import ctime HOST = '' PORT = 9999 BUFSIZ = 1024 ADDR ...
- Fiddler 抓包工具
序章 Fiddler是一个蛮好用的抓包工具,可以将网络传输发送与接受的数据包进行截获.重发.编辑.转存等操作.也可以用来检测网络安全.反正好处多多,举之不尽呀!当年学习的时候也蛮费劲,一些蛮实用隐藏的 ...
- css一些基础效果
1.旋转 .center>.bj>.div1>ul>li>.img1:hover {transform: rotate(-360deg);transition: 1s}/ ...
- WebSocketTest 异步通讯,实时返回数据
using System;using System.Net;using System.Net.Sockets;using System.Text;using System.Threading;usin ...
- Windows下安装Confluence并破解汉化
注:本文来源于<Windows下安装Confluence并破解汉化> 一.事前准备 1:JDK下载并安装:jdk-6u45-windows-i586.exe 2:MySQL JDBC连接驱 ...
- 创建表空间、新增用户、给用户赋予DBA权限 、删除用户下的上有数据表
正文原创 一:查询数据库实例有多少用户: [oracle@localhost ~]$ sqlplus / as sysdba; SQL*Plus: Release 11.2.0.3.0 Product ...