摘要: 归并排序 (求逆序数) 归并排序:递归+合并+排序 时间复杂度:O(n logn) 空间复杂度:O(n) 用途:1.排序 2.求逆序对数 Description In this problem, you have to analyze a particular sorting algorithm. 阅读全文
posted @ 2015-08-04 20:39 tmj 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 油田问题(L - 暴力求解、DFS) Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with o 阅读全文
posted @ 2015-08-04 17:14 tmj 阅读(316) 评论(0) 推荐(0) 编辑
摘要: 判断字符相等 Description Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are cal 阅读全文
posted @ 2015-08-02 21:11 tmj 阅读(277) 评论(0) 推荐(0) 编辑
摘要: Equal Sum Sets Let us consider sets of positive integers less than or equal to n. Note that all elements of a set aredifferent. Also note that the ord 阅读全文
posted @ 2015-08-02 20:17 tmj 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Tom and paper Description There is a piece of paper in front of Tom, its length and width are integer. Tom knows the area of this paper, he wants to k 阅读全文
posted @ 2015-07-31 21:47 tmj 阅读(197) 评论(0) 推荐(0) 编辑
摘要: A. Case of the Zeros and Ones Description Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containi 阅读全文
posted @ 2015-07-31 21:27 tmj 阅读(467) 评论(0) 推荐(0) 编辑
摘要: 循环次数 Description 我们知道,在编程中,我们时常需要考虑到时间复杂度,特别是对于循环的部分。例如, 如果代码中出现 for(i=1;i<=n;i++) OP ; 那么做了n次OP运算,如果代码中出现 fori=1;i<=n; i++) for(j=i+1;j<=n; j++) OP; 阅读全文
posted @ 2015-07-30 20:38 tmj 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 素数环(暴力)(紫书194页) Description A ring is composed of n (even number) circles as shown in diagram. Put natural numbers <!-- MATH: $1, 2, \dots, n$ --> int 阅读全文
posted @ 2015-07-30 17:25 tmj 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 数矩形 Description 给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形,下图为高为2,宽为4的网格. <!--StartFragment --> Description 给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形,下图为高为2,宽为4的网格. <!--St 阅读全文
posted @ 2015-07-30 10:36 tmj 阅读(347) 评论(0) 推荐(0) 编辑
摘要: 巡逻机器人问题(F - BFS,推荐) Description A robot has to patrol around a rectangular area which is in a form of <!-- MATH $m \times n$ -->mxn grid (m rows and n 阅读全文
posted @ 2015-07-29 19:39 tmj 阅读(707) 评论(0) 推荐(0) 编辑
摘要: Description Given a sequence of integers S = {S1, S2, . . . , Sn}, you should determine what is the value of themaximum positive product involving con 阅读全文
posted @ 2015-07-29 16:39 tmj 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 除法 Description <!--Converted with LaTeX2HTML 98.1 release (February 19th, 1998) originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University o 阅读全文
posted @ 2015-07-29 08:44 tmj 阅读(246) 评论(0) 推荐(0) 编辑
摘要: N皇后问题 Description 在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Description 在N*N的方格棋盘放置了N个皇后,使得它们不相互 阅读全文
posted @ 2015-07-26 22:05 tmj 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 二叉树遍历问题 Description <!--Converted with LaTeX2HTML 98.1 release (February 19th, 1998) originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, Univers 阅读全文
posted @ 2015-07-26 21:09 tmj 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 士兵排队问题 Description 某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流 阅读全文
posted @ 2015-07-26 17:27 tmj 阅读(538) 评论(0) 推荐(0) 编辑
摘要: 纸牌游戏解题报告 在写题目之前,还是要讲一下队列。 队列:“先进先出”,又称公平队列。注意:队列不需要定义大小。 头文件:<queue> 定义/声明方式:queue<int> s; push():入队、 pop():出队 front():取队首元素,但不删除,返回queue内的第一个元素 back( 阅读全文
posted @ 2015-07-26 15:06 tmj 阅读(510) 评论(0) 推荐(0) 编辑
摘要: A Currency System in Geraldion Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Description A magic island Geraldion, 阅读全文
posted @ 2015-07-25 15:24 tmj 阅读(373) 评论(0) 推荐(0) 编辑
摘要: 平衡的括号 这道题目主要运用栈的一些知识。栈在第五章的STL里已经讲了一些,这里再复习一下。 栈的特点是“先进后出”。头文件是<stack>,声明方式:"stack<int> s"。 主要有以下几个操作: push():把元素压入“栈顶”,又称入栈 pop():从栈顶把元素弹出,出栈 top():取 阅读全文
posted @ 2015-07-24 20:15 tmj 阅读(681) 评论(0) 推荐(0) 编辑
摘要: 找丢失的数 题目大意: There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers it lose. 阅读全文
posted @ 2015-07-19 20:18 tmj 阅读(398) 评论(0) 推荐(0) 编辑
摘要: 年龄排序 题目大意: You are given the ages (in years) of all people of a country with at least 1 year of age. You know thatno individual in that country lives 阅读全文
posted @ 2015-07-18 11:41 tmj 阅读(459) 评论(0) 推荐(0) 编辑
摘要: 大巧克力问题 题目大意: Mohammad has recently visited Switzerland . As he loves his friends very much, he decided to buy some chocolate for them, but as this fin 阅读全文
posted @ 2015-07-17 21:39 tmj 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 整理花园问题 题目大意: 有三户人家共拥有一座花园,每户人家的太太均需帮忙整理花园。A 太太工作了5 天,B 太太则工作了4 天,才将花园整理完毕。C 太太因为正身怀六甲无法加入她们的行列,便出了90元。请问这笔钱如何分给A、B 二位太太较为恰当?A 应得多少元?90/(5+4)*5=$50 元?如 阅读全文
posted @ 2015-07-17 16:05 tmj 阅读(553) 评论(0) 推荐(0) 编辑
摘要: 可乐商店问题 题目大意: Once upon a time, there is a special coco-cola store. If you return three empty bottles to the shop,you’ll get a full bottle of coco-cola 阅读全文
posted @ 2015-07-17 15:34 tmj 阅读(495) 评论(0) 推荐(0) 编辑
摘要: 十进制转换十六进制问题 题目大意: 把十进制整数转换为十六进制,格式为0x开头,10~15由大写字母A~F表示。 要求: Input 每行一个整数x,0<= x <= 2^31。 Input 每行一个整数x,0<= x <= 2^31。 每行一个整数x,0<= x <= 2^31。 每行一个整数x, 阅读全文
posted @ 2015-07-17 11:50 tmj 阅读(928) 评论(0) 推荐(0) 编辑
摘要: 建金字塔问题 题目大意: Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid mus 阅读全文
posted @ 2015-07-17 11:28 tmj 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 买香蕉问题 题目大意: 士兵想买W个香蕉。买第一个香蕉K美元,第二个2K美元,以此类推,第i 个香蕉iK美元。 现在该士兵有n美元,而他想买W个香蕉,他需要向他的朋友借多少美元? 要求: 输入:第一行输入整数K,n,W(其中1 ≤ K, W ≤ 1000, 0 ≤ n ≤ 109),分别表示第一个香 阅读全文
posted @ 2015-07-17 09:39 tmj 阅读(276) 评论(0) 推荐(0) 编辑