周赛 POJ 3934 Queue
Description
Linda is a teacher in ACM kindergarten. She is in charge of n kids. Because the dinning hall is a little bit far away from the classroom, those n kids have to walk in line to the dinning hall every day. When they are walking in line, if and only if two kids
can see each other, they will talk to each other. Two kids can see each other if and only if all kids between them are shorter then both of them, or there are no kids between them. Kids do not only look forward, they may look back and talk to kids behind them. Linda don’t want them to talk too much (for it’s not safe), but she also don’t want them to be too quiet(for it’s boring), so Linda decides that she must form a line in which there are exactly m pairs of kids who can see each other. Linda wants to know, in how many different ways can she form such a line. Can you help her? Note: All kids are different in height. Input
Input consists of multiple test cases. Each test case is one line containing two integers. The first integer is n, and the second one is m. (0 < n <= 80, 0 <= m <= 10000).
Input ends by a line containing two zeros. Output
For each test case, output one line containing the reminder of the number of ways divided by 9937.
Sample Input 1 0 Sample Output 1 答案要模上9937,都会想到是递推吧,关键怎么推。 思路:i个人j对可由 1:i-1个人j-2对再插入一个最小的人,所以对原来的组合没有影响 2:i-2个人j-1对,再在两边插入一个人,对原来的组合也没有影响。 #include<iostream> |
周赛 POJ 3934 Queue的更多相关文章
- POJ 3934 Queue(DP)
Queue Description Linda is a teacher in ACM kindergarten. She is in charge of n kids. Because the di ...
- POJ 3481Double Queue Splay
#include<stdio.h> #include<string.h> ; ],data[N],id[N],fa[N],size,root; void Rotate(int ...
- {POJ}{动态规划}{题目列表}
动态规划与贪心相关: {HDU}{4739}{Zhuge Liang's Mines}{压缩DP} 题意:给定20个点坐标,求最多有多少个不相交(点也不相交)的正方形 思路:背包问题,求出所有的正方形 ...
- [ACM训练] 算法初级 之 数据结构 之 栈stack+队列queue (基础+进阶+POJ 1338+2442+1442)
再次面对像栈和队列这样的相当基础的数据结构的学习,应该从多个方面,多维度去学习. 首先,这两个数据结构都是比较常用的,在标准库中都有对应的结构能够直接使用,所以第一个阶段应该是先学习直接来使用,下一个 ...
- poj 3841 Double Queue (AVL树入门)
/****************************************************************** 题目: Double Queue(poj 3481) 链接: h ...
- POJ 3481 Double Queue STLmap和set新学到的一点用法
2013-08-08 POJ 3481 Double Queue 这个题应该是STL里较简单的吧,用平衡二叉树也可以做,但是自己掌握不够- -,开始想用两个优先队列,一个从大到小,一个从小到大,可是 ...
- POJ 2259 - Team Queue - [队列的邻接表]
题目链接:http://poj.org/problem?id=2259 Queues and Priority Queues are data structures which are known t ...
- poj 2259 Team Queue
Team Queue Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 2977 Accepted: 1092 Descri ...
- POJ 3481 Double Queue(Treap模板题)
Double Queue Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15786 Accepted: 6998 Des ...
随机推荐
- (一) Mysql 简介及安装和配置
第一节:Mysql 简介 百度百科 第二节:Mysql 安装及配置 1,Mysql5.1 下载及安装 2,Mysql 数据库编码配置 utf-8 3,Mysql 图形界面 Sqlyog 下载及安装
- 以太坊go-ethereum客户端docker安装(一)
最近一段时间忙于工作,就没来得及发表博客,但一直没有停止对区块链的研究.周末抽时间分享一下近期比较重大的收获之一--使用docker来搭建和使用以太坊的节点.本人已经顺利搭建出,开发环境,测试环境,F ...
- 进程自我保护 适用于WIN7 X64
//进程自我保护,注意只有X64 WIN7可用 #include <ntddk.h> #define PROCESS_TERMINATE 1 typedef struct _LDR_DAT ...
- 使用递归计算n的阶乘n!
计算n! 观察公式2可以直接使用递归求解 C++代码如下: #include <iostream> using namespace std; unsigned func(unsigned ...
- 使用 JQuery 实现将 table 按照列排序
使用 JQuery 实现将 table 按照列排序 使用 JQuery 实现将 table 按照列排序 代码如下 <!DOCTYPE html> <html> <head ...
- Java 单例模式的七种写法
Java 单例模式的七种写法 第一种(懒汉,线程不安全) public class Singleton { private static Singleton instance; private Sin ...
- BNUOJ 52506 Captcha Cracker
简单模拟题. #include<bits/stdc++.h> using namespace std; ]; int T; int main() { scanf("%d" ...
- Django+Nginx+uwsgi搭建自己的博客(七)
上一篇博客中介绍了Blogs App的部分后端功能的实现,在这篇博客中,将继续为大家介绍Blogs App中前端功能的实现. 首先来看发布博客功能的前端页面.在blogs/templates/blog ...
- java自定义类
引用数据类型(类) 引用数据类型分类 提到引用数据类型(类),其实我们对它并不陌生,之前使用过的Scanner类.Random类. 我们可以把类的类型为两种: 第一种,Java为我们提供好的类,如Sc ...
- Ubuntu16.04安装mongodb 及使用
1.导入软件源的公钥 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 2.为mongodb创建软件 ...