- 博客(28)
- 收藏
- 关注
原创 Dividing
Description Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbl
2014-08-22 21:14:24 285
原创 Factorial
Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and
2014-08-22 21:06:25 237
原创 Sum it up
Description Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t = 4, n = 6, and the list is [4, 3, 2, 2, 1,
2014-08-22 20:39:52 274
原创 oil deposits
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a gri
2014-08-22 20:05:06 271
原创 骑士漫游
Description 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 world. Whenever a knight moves, it is
2014-08-22 19:03:00 805
原创 TKP(BFS)
Description A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squa
2014-08-22 18:06:20 348
原创 BFS经典题
Description 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 number line and the cow is at a point
2014-08-22 10:45:39 273
原创 queue
一.queue模版类的定义在头文件中。 queue与stack模版非常类似,queue模版也需要定义两个模版参数,一个是元素类型,一个是容器类型,元素类型是必要的,容器类型是可选的,默认为dqueue类型。 定义queue对象的示例代码如下: queueq1; queueq2; queue的基本操作有: 1.入队:如q.push(x):将x元素接到队列的末端;
2014-08-22 10:42:01 300
原创 迷宫问题
Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, }; 它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短
2014-08-22 01:13:42 403
原创 非常可乐
Description 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S Input 三个整数 : S 可乐的体积 , N 和 M
2014-08-22 01:12:26 295
原创 An Easy Problem!
Description Have you heard the fact "The base of every normal number system is 10" ? Of course, I am not talking about number systems like Stern Brockot Number System. This problem has nothing to
2014-08-20 23:44:37 262
原创 反正切函数的应用
Description 反正切函数可展开成无穷级数,有如下公式 (其中0 使用反正切函数计算PI是一种常用的方法。例如,最简单的计算PI的方法: PI=4arctan(1)=4(1-1/3+1/5-1/7+1/9-1/11+...) 公式(2) 然而,这种方法的效率很低,但我们可以根据角度和的正切函数公式: tan(a+b)=[tan(a)+tan
2014-08-20 21:36:46 595
原创 Perfect Pth Powers
Description We say that x is a perfect square if, for some integer b, x = b 2. Similarly, x is a perfect cube if, for some integer b, x = b 3. More generally, x is a perfect pth power if, for s
2014-08-20 11:26:34 352
原创 Break Standard Weight
Description The balance was the first mass measuring instrument invented. In its traditional form, it consists of a pivoted horizontal lever of equal length arms, called the beam, with a weighing p
2014-08-19 15:52:46 292
原创 stl基础 set集合
#include #include #include #include using namespace std; /* set和multiset的内部结构通常是由平衡二叉树来实现的。当元素放入容器中时,会按照一定的排序法则自动排序,默认是按照less<>排序规则来排序。这种自动排序的特性加速了元素查找的过程,但是也带来了一个问题,不可以直接修改set或multi
2014-08-19 15:52:03 228
原创 报数游戏
Description n个人站成一行玩一个报数游戏。所有人从左到右编号为1到n。游戏开始时,最左边的人报1,他右边的人报2,编号为3的人报3,等等。当编号为n的人(即最右边的人)报完n之后,轮到他左边的人(即编号为n-1的人)报n+1,然后编号为n-2的人报n+2,以此类推。当最左边的人再次报数之后,报数方向又变成从左到右,依次类推。 为了防止游戏太无聊,报数时有一个特例:如果应该报的
2014-08-15 20:39:00 612
原创 盒子游戏
Description 有两个相同的盒子,其中一个装了n个球,另一个装了一个球。Alice和Bob发明了一个游戏,规则如下:Alice和Bob轮流操作,Alice先操作每次操作时,游戏者先看看哪个盒子里的球的数目比较少,然后清空这个盒子(盒子里的球直接扔掉),然后把另一个盒子里的球拿一些到这个盒子中,使得两个盒子都至少有一个球。如果一个游戏者无法进行操作,他(她)就输了。下图是一个典型的游戏
2014-08-15 20:01:37 440
原创 Sum It Up
Description Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t = 4, n = 6, and the list is [4, 3, 2, 2, 1,
2014-08-14 22:57:48 255
原创 Robot Motion(水题)
Description 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 grid. The possible instructions are
2014-08-14 22:31:11 330
原创 DFS剪枝
Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized
2014-08-14 21:05:43 286
原创 Necklace (线段树单点更新+区间查询+离线操作)
Problem Description Mery has a beautiful necklace. The necklace is made up of N magic balls. Each ball has a beautiful value. The balls with the same beautiful value look the same, so if two or mor
2014-08-13 20:02:35 344
原创 find the mincost route(floyd算法)
Description 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K>2,就是说至除了出发点以外至少要经过2个其他不同的景区,而且不能重复经过同一个景区。现在8600需要你帮他找一条这样的路线,并且花费越少越好。 Input 第一
2014-08-13 16:27:00 334
原创 贪心的kruskal最小生成树算法
Description XX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Structure---超级空中漫游结构)进行交流,每条SARS都对行驶在上面的Flycar限制了固定的Speed,同时XX星人对 Flycar的“舒适度”有特殊要求,即乘坐过程中最高速度与最低速度的差越小乘坐越舒服 ,(理解为SARS的限速要求,flycar必须瞬间提速/降速,痛
2014-08-12 19:58:00 362
原创 过山车-二分图最大匹配
Description RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子
2014-08-12 19:45:09 364
原创 最短路,dijkstra算法。
Description Earth Hour is an annual international event created by the WWF (World Wide Fund for Nature/World Wildlife Fund), held on the last Saturday of March, that asks households and businesses
2014-08-12 17:14:45 343
原创 畅通工程续
Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。 Input 本题目包含多组数据,请处理到文件结束。 每组数据
2014-08-10 23:45:02 362
原创 畅通工程 NO.2
Description 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。 Input 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N
2014-08-10 23:39:39 591
原创 畅通工程 NO.1
Description 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。 Input 测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M (
2014-08-10 23:11:12 286
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人