摘要: 题目: We give the following inductive definition of a “regular brackets” sequence: the empty sequence is a regular brackets sequence, if s is a regular 阅读全文
posted @ 2017-08-17 08:07 你的女孩居居 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 题目: 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以 阅读全文
posted @ 2017-08-14 10:42 你的女孩居居 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 题目: The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flat 阅读全文
posted @ 2017-08-10 20:46 你的女孩居居 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 题目: 相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符 阅读全文
posted @ 2017-08-10 20:35 你的女孩居居 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 题目: 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input 测试输入包含若干测试用例。每个测试用例的 阅读全文
posted @ 2017-08-07 20:42 你的女孩居居 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 老师发群里的一本书,在网上都没有发现比这个更加详细的讲解了,放上两种算法讲解的截图: 阅读全文
posted @ 2017-08-07 20:29 你的女孩居居 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 题目: Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To mini 阅读全文
posted @ 2017-08-06 20:41 你的女孩居居 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 题目: The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C 阅读全文
posted @ 2017-08-05 10:40 你的女孩居居 阅读(1202) 评论(0) 推荐(1) 编辑
摘要: 卡特兰数: Catalan数 原理: 令h(1)=1,h(0)=1,catalan数满足递归式: h(n)= h(1)*h(n-1) + h(2)*h(n-2) + ... + h(n-1)h(1) (其中n>=2) 另类递归式: h(n)=((4*n-2)/(n+1))*h(n-1); 该递推关系 阅读全文
posted @ 2017-08-03 19:54 你的女孩居居 阅读(686) 评论(0) 推荐(0) 编辑
摘要: 题目: Emily the entrepreneur has a cool business idea: packaging and selling snowflakes. She has devised a machine that captures snowflakes as they fall 阅读全文
posted @ 2017-08-03 19:29 你的女孩居居 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 题目: 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种。如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 Input 输入两个整数M,N.1<=M<=10^8,1<=N<=10^12 Output 可能越狱的状态数,模1000 阅读全文
posted @ 2017-08-02 20:53 你的女孩居居 阅读(192) 评论(0) 推荐(0) 编辑
摘要: gcd(最大公因数)和lcm(最小公倍数) 辗转相除法求a和b的最大公因数和最小公倍数: 最小公倍数=a*b/最大公约数; 求最大公因数: 求最小公倍数: 题目: There is a hill with n holes around. The holes are signed from 0 to 阅读全文
posted @ 2017-08-02 20:50 你的女孩居居 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 题目: 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样。 话虽这样说,我还是要告诉大家,要想失败到一定程度也是不容易的。比如,我高中的时候,就有一个神奇的女生,在英语考试的时候 阅读全文
posted @ 2017-08-02 20:48 你的女孩居居 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 欧拉函数: 在数论,对正整数n,欧拉函数是少于或等于n的数中与n互质的数的数目。此函数以其首名研究者欧拉命名,它又称为Euler's totient function、φ函数、欧拉商数等。 例如φ(8)=4,因为1,3,5,7均和8互质。 从欧拉函数引伸出来在环论方面的事实和拉格朗日定理构成了欧拉定 阅读全文
posted @ 2017-08-01 10:29 你的女孩居居 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 二分查找的实现与应用: 在学习算法的过程中,我们除了要了解某个算法的基本原理、实现方式,更重要的一个环节是利用big-O理论来分析算法的复杂度。在时间复杂度和空间复杂度之间,我们又会更注重时间复杂度。 时间复杂度按优劣排差不多集中在: O(1), O(log n), O(n), O(n log n) 阅读全文
posted @ 2017-07-30 17:10 你的女孩居居 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 快速排序 快速排序(QuickSort)划分的关键是要求出基准记录所在的位置pivotpos,编程时候的关键点 快速排序: 既然能把冒泡KO掉,马上就激起我们的兴趣,tnd快排咋这么快,一定要好好研究一下。 首先上图: 从图中我们可以看到: left指针,right指针,base参照数。 其实思想是 阅读全文
posted @ 2017-07-30 16:53 你的女孩居居 阅读(1520) 评论(0) 推荐(0) 编辑
摘要: 归并排序: 归并排序是建立在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。 首先考虑下如何将将二个有序数列合并。这个非常简单,只要从比较二个数列的第一个数,谁小就先取谁,取了后就在对应数列中删除这个数。然后再进行比较,如果有数列为空, 阅读全文
posted @ 2017-07-30 16:43 你的女孩居居 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 题目: 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包含若干测试用例。每个测试用例的第1行给出 阅读全文
posted @ 2017-07-29 10:13 你的女孩居居 阅读(126) 评论(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 你的女孩居居 阅读(263) 评论(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 你的女孩居居 阅读(316) 评论(0) 推荐(0) 编辑
摘要: 题目: The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvCompworkswithonelargerectangularregionofland 阅读全文
posted @ 2017-07-26 15:13 你的女孩居居 阅读(2576) 评论(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 你的女孩居居 阅读(2874) 评论(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 你的女孩居居 阅读(227) 评论(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 你的女孩居居 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://vjudge.net/problem/CodeForces-546B AC代码: 阅读全文
posted @ 2017-07-24 17:06 你的女孩居居 阅读(196) 评论(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 你的女孩居居 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://vjudge.net/problem/HYSBZ-1029 题目分析: 刚开始看题目,我以为建立一个包含t1,t2的结构体,然后将所有建筑维修的摧毁时间进行排序,最后从小到大的将维修时间t1进行相加就可以了,结果WA; 后来发现如果前面修缮好的建筑的时间过长就有可能会耽误后 阅读全文
posted @ 2017-07-22 16:35 你的女孩居居 阅读(176) 评论(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 你的女孩居居 阅读(217) 评论(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 你的女孩居居 阅读(222) 评论(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 你的女孩居居 阅读(193) 评论(0) 推荐(0) 编辑