07 2017 档案

摘要:二分查找的实现与应用: 在学习算法的过程中,我们除了要了解某个算法的基本原理、实现方式,更重要的一个环节是利用big-O理论来分析算法的复杂度。在时间复杂度和空间复杂度之间,我们又会更注重时间复杂度。 时间复杂度按优劣排差不多集中在: O(1), O(log n), O(n), O(n log n) 阅读全文
posted @ 2017-07-30 17:10 你的女孩居居 阅读(193) 评论(0) 推荐(0)
摘要:快速排序 快速排序(QuickSort)划分的关键是要求出基准记录所在的位置pivotpos,编程时候的关键点 快速排序: 既然能把冒泡KO掉,马上就激起我们的兴趣,tnd快排咋这么快,一定要好好研究一下。 首先上图: 从图中我们可以看到: left指针,right指针,base参照数。 其实思想是 阅读全文
posted @ 2017-07-30 16:53 你的女孩居居 阅读(1566) 评论(0) 推荐(0)
摘要:归并排序: 归并排序是建立在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。 首先考虑下如何将将二个有序数列合并。这个非常简单,只要从比较二个数列的第一个数,谁小就先取谁,取了后就在对应数列中删除这个数。然后再进行比较,如果有数列为空, 阅读全文
posted @ 2017-07-30 16:43 你的女孩居居 阅读(224) 评论(0) 推荐(0)
摘要:题目: 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包含若干测试用例。每个测试用例的第1行给出 阅读全文
posted @ 2017-07-29 10:13 你的女孩居居 阅读(142) 评论(0) 推荐(0)
摘要:题目: Background The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the wor 阅读全文
posted @ 2017-07-27 14:53 你的女孩居居 阅读(281) 评论(0) 推荐(0)
摘要:题目: A university network is composed of N computers. System administrators gathered information on the traffic between nodes, and carefully divided th 阅读全文
posted @ 2017-07-26 20:25 你的女孩居居 阅读(331) 评论(0) 推荐(0)
摘要:题目: The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvCompworkswithonelargerectangularregionofland 阅读全文
posted @ 2017-07-26 15:13 你的女孩居居 阅读(2607) 评论(0) 推荐(1)
摘要:题目: You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with r 阅读全文
posted @ 2017-07-26 15:00 你的女孩居居 阅读(2938) 评论(0) 推荐(0)
摘要:题目: Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a 阅读全文
posted @ 2017-07-26 14:48 你的女孩居居 阅读(236) 评论(0) 推荐(0)
摘要:题目: 有一个长方形的房间,覆盖了正方形的磁砖。每块磁砖的颜色,要么是红色,要么是黑色。一名男子站在一块黑色的磁砖上。他可以从一块磁砖移至相邻四块磁砖中的某一块。但是,他不允许在红色磁砖上移动,他只允许在黑色磁砖上移动。 编写一个程序,使得他允许重复上述的移动,判断他所能到达的黑色磁砖的数量。 输入 阅读全文
posted @ 2017-07-24 19:57 你的女孩居居 阅读(136) 评论(0) 推荐(0)
摘要:题目: A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a gr 阅读全文
posted @ 2017-07-24 17:07 你的女孩居居 阅读(211) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/problem/CodeForces-546B AC代码: 阅读全文
posted @ 2017-07-24 17:06 你的女孩居居 阅读(214) 评论(0) 推荐(0)
摘要:题目: Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especiall 阅读全文
posted @ 2017-07-24 15:38 你的女孩居居 阅读(308) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/problem/HYSBZ-1029 题目分析: 刚开始看题目,我以为建立一个包含t1,t2的结构体,然后将所有建筑维修的摧毁时间进行排序,最后从小到大的将维修时间t1进行相加就可以了,结果WA; 后来发现如果前面修缮好的建筑的时间过长就有可能会耽误后 阅读全文
posted @ 2017-07-22 16:35 你的女孩居居 阅读(187) 评论(0) 推荐(0)
摘要:题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=72 题意: 求以2,3,5为唯一因子的第1500个数字(丑数) AC代码: 阅读全文
posted @ 2017-07-22 15:56 你的女孩居居 阅读(229) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/problem/UVA-514 题目大意: 有A,B,C三个火车停靠点,火车最初停在A站,给你一个序列,问你能不能通过中转站C到达B站,火车从A站进入到C站以后不能再返回A站,从C站出到B站以后不能再进入C站。 分析: 把中转站C站看作一个栈。 暑假集 阅读全文
posted @ 2017-07-22 15:33 你的女孩居居 阅读(234) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1276 1.注意要写出输入1~3的情况 2.当num==2或者等于3的时候,记得将num赋值为0; AC代码: 阅读全文
posted @ 2017-07-20 20:28 你的女孩居居 阅读(202) 评论(0) 推荐(0)
摘要:大数相加: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 1.程序中大数的输入采用的是字符串的形式(C语言中的char数组或者C++中的string字符串) 2.存放相加后结果的数组定义成int类型会比较容易书写 3.后尾对齐,满十进一的原则 阅读全文
posted @ 2017-07-20 10:13 你的女孩居居 阅读(237) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1027 题目是要:求n个数的第m个全排列 代码:(超时) #include<iostream>#include<algorithm>using namespace std;const int N=1005 阅读全文
posted @ 2017-07-19 21:20 你的女孩居居 阅读(130) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/contest/171027#problem/E Yes的输出条件: 1. 空字符串 2.形如()[]; 3.形如([])或者[()] 分析: 1.设置一个变量flag,初始值为1 (注意初始化的位置); 2.括号的左半边入栈; 3.若发现括号右半边的 阅读全文
posted @ 2017-07-19 20:52 你的女孩居居 阅读(370) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1237 ***栈的使用*** 分析: 例子: 4 + 2 * 5 - 7 / 11 其中每两个整数中间有一个空格,因此输入时选择先输入一个整数和一个字符(空格),后面输入的就都是一个字符串(包括一个运算符 阅读全文
posted @ 2017-07-19 20:18 你的女孩居居 阅读(298) 评论(0) 推荐(0)
摘要:头文件:#include<algorithm> * * * 1. next_permutation(): next_permutation()函数的返回类型是bool类型. 即:如果有一个更高的排列,它重新排列元素,并返回true;如果这是不可能的(因为它已经在最大可能的排列),它按升序排列重新元素 阅读全文
posted @ 2017-07-17 13:42 你的女孩居居 阅读(4048) 评论(0) 推荐(1)