摘要: 题目: 输入一棵二叉树,你的任务是按从上到下、从左到右的顺序输出各个结点的值。每个结点都按照从根结点到它的移动序列给出(L表示左,R表示右)。在输入中,每个结点的左括号和右括号之间没有空格,相邻结点之间用一个空格隔开。每棵树的输入用一对空括号()结束(这对括号本身不代表一个结点)。注意:如果从根到某 阅读全文
posted @ 2020-04-14 17:39 _Dinosaur_Po 阅读(228) 评论(0) 推荐(0)
摘要: 题目描述有一棵二叉树,最大深度为D,且所有叶子的深度都相同。所有结点从上到下从左到右编号为1,2,3,…,2D-1。在结点1处放一个小球,它会往下落。每个内结点上都有一个开关,初始全部关闭,当每次有小球落到一个开关上时,它的状态都会改变。当小球到达一个内结点时,如果该结点上的开关关闭,则往左走,否则 阅读全文
posted @ 2020-04-14 00:20 _Dinosaur_Po 阅读(175) 评论(0) 推荐(0)
摘要: UVA 12657 Boxes in a Line You have n boxes in a line on the table numbered 1 . . . n from left to right. Your task is to simulate 4kinds of commands:• 阅读全文
posted @ 2020-04-12 23:30 _Dinosaur_Po 阅读(152) 评论(0) 推荐(0)
摘要: You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem with the keyboard is that sometimes the “home” key o 阅读全文
posted @ 2020-04-11 16:21 _Dinosaur_Po 阅读(165) 评论(0) 推荐(0)
摘要: 注意输出格式 1 /*对于已经给出的入栈顺序判断出栈顺序是否正确*/ 2 3 #include<iostream> 4 #include<stack> 5 #include<cstdio> 6 using namespace std; 7 const int num = 1000 + 10; 8 i 阅读全文
posted @ 2020-04-10 13:01 _Dinosaur_Po 阅读(100) 评论(0) 推荐(0)
摘要: 卡特兰数又称卡塔兰数,卡特兰数是组合数学中一个常出现在各种记数问题中的数列。 原理: 设h(n)为catalan数的第n+1项,令h(0)=1,h(1)=1,catalan数满足递推式 : h(n)= h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)*h(0) (n>=2 阅读全文
posted @ 2020-04-10 10:55 _Dinosaur_Po 阅读(2685) 评论(1) 推荐(4)
摘要: 1 #include<iostream> 2 #include<stack> 3 #include<queue> 4 #include<algorithm> 5 using namespace std; 6 7 int n; 8 char a[5000]; 9 10 void dfs(queue<c 阅读全文
posted @ 2020-04-09 09:08 _Dinosaur_Po 阅读(320) 评论(0) 推荐(0)