算法入门
文章平均质量分 71
锅巴QAQ
三十年河东,三十年河西!
展开
-
史上最明白:分治---归并排序,小学生也学会
数组排序任务可以如下完成:1) 把前一半排序2) 把后一半排序3) 把两半归并到一个新的有序数组,然后再拷贝回原数组,排序完成。分治的典型应用:归并排序分治的典型应用:归并排序#include using namespace std;void Merge(int a[],int s,int m, int e,int tmp[]){//将数组a的局部a[s,m]和a[m原创 2017-03-15 20:15:26 · 405 阅读 · 0 评论 -
2021春招-十大排序-待完善
2020年11月27日冒泡排序比较相邻的元素。如果第一个比第二个大,就交换他们两个。对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对。这步做完后,最后的元素会是最大的数。针对所有的元素重复以上的步骤,除了最后一个。持续每次对越来越少的元素重复上面的步骤,直到没有任何一对数字需要比较。什么时候最快当输入的数据已经是正序时(都已经是正序了,我还要你冒泡排序有何用啊)。什么时候最慢当输入的数据是反序时(写一个 for 循环反序输出数据不就行了,干嘛要用你冒泡排序呢,我原创 2020-11-27 15:13:18 · 309 阅读 · 0 评论 -
算法设计与分析
这里写自定义目录标题统计数字问题新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入统计数字问题本着书本页码不会...原创 2019-11-17 13:14:00 · 304 阅读 · 0 评论 -
K - 迷宫问题 POJ - 3984
定义一个二维数组: 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表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上原创 2017-03-31 17:01:18 · 564 阅读 · 0 评论 -
E - Find The Multiple POJ - 1426
Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there原创 2017-03-31 16:58:34 · 392 阅读 · 0 评论 -
C - Catch That Cow POJ - 3278
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 K (0 ≤ K ≤ 100原创 2017-03-31 16:56:00 · 442 阅读 · 0 评论 -
B - Dungeon Master POJ - 2251
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 rock. It takes one minute to move one unit north, south原创 2017-03-31 16:37:08 · 503 阅读 · 0 评论 -
A - 棋盘问题 POJ - 1321
两个棋子不能放在棋盘中的同一行或者同一列两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n 当为-1 -1时表示输入结束。 随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区域, . 表示空白区域Sample Input2 1#..#4 2...#..#..#..#...-1原创 2017-03-31 16:35:36 · 4381 阅读 · 1 评论 -
Catch That Cow(抓住那头牛)
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 K (0 ≤ K ≤ 100,0原创 2017-03-28 21:50:39 · 583 阅读 · 0 评论 -
Mid-Central USA 1997--Oil Deposits (油田问题)
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 grid that divides th原创 2017-03-28 21:32:04 · 1635 阅读 · 0 评论 -
POJ2236 Wireless Network
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the原创 2017-04-27 18:43:12 · 521 阅读 · 0 评论 -
poj 2387---Til the Cows Come Home
Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b原创 2017-04-26 20:59:23 · 436 阅读 · 0 评论 -
L - Oil Deposits HDU - 1241
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 grid that divides th原创 2017-03-31 17:03:37 · 473 阅读 · 0 评论 -
哈希算法---Snowflake Snow Snowflakes
Time limit4000 msMemory limit65536 kBOSLinuxYou may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really tru原创 2017-04-12 21:52:43 · 601 阅读 · 0 评论 -
POJ1797 Heavy Transportation
Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his cu原创 2017-05-01 09:53:09 · 545 阅读 · 0 评论 -
POJ 2253 Frogger
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sun原创 2017-05-01 09:14:09 · 433 阅读 · 0 评论 -
POJ2534 Ubiquitous Religions
There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university beli原创 2017-04-27 17:20:35 · 512 阅读 · 0 评论 -
HDU5631 Rikka with Graph
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has a non-direct graph with n vertices and n+1 e原创 2017-05-06 11:27:53 · 462 阅读 · 0 评论 -
POJ3268 Silver Cow Party
One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M≤ 100,000) unidirectional (one-way r原创 2017-05-06 10:54:26 · 394 阅读 · 0 评论 -
POJ1611 The Suspects
Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to原创 2017-04-27 18:51:44 · 387 阅读 · 0 评论 -
哈希算法---Eqs
Consider equations having the following form: a1x1 3+ a2x2 3+ a3x3 3+ a4x4 3+ a5x5 3=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1, x2,原创 2017-04-13 18:21:27 · 876 阅读 · 0 评论 -
哈希算法---YY's new problem
Given a permutation P of 1 to N, YY wants to know whether there exists such three elements P[i 1], P[i 2], P[i 3] that P[i 1]-P[i 2]=P[i 2]-P[i 3], 1123InputThe first line is T(TEach test case原创 2017-04-12 22:01:35 · 487 阅读 · 0 评论 -
哈希算法---sort 前M大的数
给你n个整数,请按从大到小的顺序输出其中前m大的数。 Input每组测试数据有两行,第一行有两个数n,m(0−500000,500000−500000,500000的整数。 Output对每组测试数据按从大到小的顺序输出前m大的数。 Sample Input5 33 -35 92 213 -644Sample Output213 92 3原创 2017-04-12 21:59:41 · 1416 阅读 · 0 评论 -
哈希算法---Equations
All the problems in this contest totally bored you. And every time you get bored you like playing with quadratic equations of the form a*X 2 + b*X + c = 0. This time you are very curious to know how m原创 2017-04-12 21:58:20 · 991 阅读 · 0 评论 -
哈希算法---Babelfish
You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.InputInpu原创 2017-04-12 21:55:45 · 1130 阅读 · 0 评论 -
POJ2387 Til the Cows Come Home
Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get原创 2017-05-01 09:24:27 · 396 阅读 · 0 评论