自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

tjj1998的博客

一个萌新的算法之路

  • 博客(32)
  • 资源 (1)
  • 收藏
  • 关注

原创 【算法】最大流问题——Ford-Fulkerson算法+Dinic算法

Ford-Fulkerson算法描述:最大流问题可以看做是无向图搜索,找到一条可以使结果增加的边。不过只有当有流量出去,对应的向回推的流才有容量,二者相加等于该边总容量。不断搜索直到没有可以增加的边,则返回最大值。Ford-Fulkerson算法的复杂度为O(FE)。添加对应边struct Stream{//保存终点,流量,反向边编号 int to,cap,revNum;...

2018-03-31 15:31:06 1987

原创 【PAT】1024.Palindromic Number (25)

题目描述A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic n...

2018-03-31 13:48:09 123

原创 【PAT】1023.Have Fun with Numbers (20)

题目描述Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit numb...

2018-03-31 12:17:21 176

原创 【PAT】1022. Digital Library (30)【map的用法】

题目描述A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit nu...

2018-03-30 18:24:09 123

原创 【PAT】1021. Deepest Root (25)【深度优先搜索】

题目描述A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a...

2018-03-30 16:28:11 167

原创 【PAT】1020. Tree Traversals (25)【深度优先搜索】

题目描述Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of t...

2018-03-29 12:00:57 155

原创 【PAT】1019.General Palindromic Number (20)

题目描述A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic n...

2018-03-29 11:16:04 119

原创 【PAT】1018.Public Bike Management (30)【深度优先搜索】

题目描述There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations i...

2018-03-28 18:06:54 2894 3

原创 【PAT】1017. Queueing at Bank (25)【priority_queue的运用】

题目描述:Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the ye...

2018-03-27 15:42:22 168

原创 【PAT】1016. Phone Bills (25)【priority_queue和map的使用】

题目描述A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made...

2018-03-26 18:13:15 153

原创 【PAT】1015. Reversible Primes (20)

题目描述A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is als...

2018-03-26 12:46:26 179

原创 【PAT】1014. Waiting in Line (30)

题目描述:Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:Th...

2018-03-25 20:20:35 325

原创 【PAT】1013. Battle Over Cities (25)

题目描述:It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if...

2018-03-25 15:30:22 148

原创 【PAT】1012.The Best Rank (25) 【map容器使用】

题目描述:To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algebra), and ...

2018-03-24 16:51:19 595

原创 【PAT】1011. World Cup Betting (20)

题目描述:With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Afr...

2018-03-24 12:54:29 341

原创 【PAT】1010. Radix (25)

题目描述:Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is “yes”, if 6 is a decimal number and 110 is a binary number.Now for any pair of posi...

2018-03-23 18:35:23 367 1

原创 【PAT】1009. Product of Polynomials (25)

题目描述This time, you are supposed to find A*B where A and B are two polynomials.翻译:这一次,你需要输出运算 A和B两个多项式的乘积。INPUT FORMATEach input file contains one test case. Each case occupies 2 lines, and e...

2018-03-23 15:24:06 134

原创 【PAT】1008. Elevator (20)

题目描述The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs...

2018-03-22 14:56:29 183

原创 【PAT】1007. Maximum Subsequence Sum (25)

题目描述Given a sequence of K integers { N1, N2, …, NK }. A continuous subsequence is defined to be { Ni, Ni+1, …, Nj } where 1 <= i <= j <= K. The Maximum Subsequence is the continuous subsequ...

2018-03-22 13:23:09 224

原创 【PAT】1006. Sign In and Sign Out (25)【结构体+排序函数cmp】

题目描述At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’...

2018-03-21 09:10:23 145

原创 【PAT】1005. Spell It Right (20)

题目描述:Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.翻译:给一个非负的整数N,你的任务是将N的所有数字相加求和,然后用英文输出和的每一位数字。INPUT FOR...

2018-03-21 08:36:54 126

原创 【PAT】1004. Counting Leaves (30)【递归】

题目描述:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.翻译:一个家族按层次经常用家谱(树型结构)来展示。你的任务是计算出这些家族成员哪些人没有孩子。INPUT FORMATEach i...

2018-03-20 17:39:48 151

原创 【PAT】1003. Emergency (25)【单源最短路问题/dijkstra算法】

题目描述:As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city an...

2018-03-20 11:40:08 213

原创 【PAT】1002. A+B for Polynomials (25)

题目描述:This time, you are supposed to find A+B where A and B are two polynomials.翻译:这一次,你应当去完成两个多项式A和B的相加了。INPUT FORMATEach input file contains one test case. Each case occupies 2 lines, and eac...

2018-03-19 16:57:56 187

原创 【PAT】1001.A+B Format (20)

题目描述:Calculate a + b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits). 翻译:计算a+b然后按照标准格式输出——这代表数字...

2018-03-19 16:13:06 135

原创 【模板算法】单源最短路问题-dijkstra算法(邻接表+优先队列优化)

dijkstra算法适用范围:求一个点到另一个点或其他点的最短路问题,当然,最大路也可以,重载一下<号即可。我写的这次模板是双条件的,即除了路径长度限制还有当路径长度相同后data小的优先输出,并且还有返回路径的函数,所以普适度更高,如果做得题目不需要双条件,删除data相关内容即可。在该篇文章最后会有源代码及两组测试数据供大家测试。edge结构体定义struct edge{ ...

2018-03-17 13:05:49 964

原创 【数据结构】简单并查集的实现

并查集是一个用来管理元素分组情况的数据结构,当你需要查询两个元素是否属于同一集合,那么并查集是一个很好的选择。而且由于最小生成树中的Kruskal算法也用到了并查集,所以学习一下还是很有帮助的。并查集初始化将每个点都赋值为它自身 void init(){ for(int i=0;i<N;i++) par[i]=i;} 查找元素所在集合在此处...

2018-03-17 10:54:47 442 1

原创 【数据结构】快速实现平衡二叉树(可观察每一次插入后的结果)

为了算法考试需要,我在实验室苦熬了一天,终于从零开始学会了平衡二叉树,不过只有二叉树的插入,没有删除操作,以后如果有时间就补上。最后会附上完整代码,我在里面写了一段输出函数,顺便会给大家两组测试数据,可以观察平衡二叉树每一次插入的运行结果呦,我尽量让它看起来对称,不过数值的位数不同就没办法了,所以各位凑合着看吧OwOstruct node{ int data; int he...

2018-03-15 12:16:15 459

原创 USACO-Section4.1 Fence Loops【Floyd算法】

题目描述:农夫布朗的牧场上的篱笆已经失去控制了。它们分成了1~200英尺长的线段。只有在线段的端点处才能连接两个线段,有时给定的一个端点上会有两个以上的篱笆。结果篱笆形成了一张网分割了布朗的牧场。布朗想将牧场恢复原样,出于这个考虑,他首先得知道牧场上哪一块区域的周长最小。 布朗将他的每段篱笆从1到N进行了标号(N=线段的总数)。他知道每段篱笆有如下属性:该段篱笆的长度 该段篱笆的一端所连...

2018-03-03 19:27:32 240

原创 USACO-Section4.1 Beef McNuggets【动态规划】

题目描述:农夫布朗的奶牛们正在进行斗争,因为它们听说麦当劳正在考虑引进一种新产品:麦香牛块。奶牛们正在想尽一切办法让这种可怕的设想泡汤。奶牛们进行斗争的策略之一是“劣质的包装”。“看,”奶牛们说,“如果你只用一次能装3块、6块或者10块的三种包装盒包装麦香牛块,你就不可能满足一次只想买1、2、4、5、7、8、11、14或者17块麦香牛块的顾客了。劣质的包装意味着劣质的产品。”你的任务是帮助...

2018-03-02 13:08:41 204

原创 USACO-Section3.4 Raucous Rockers【动态规划】

题目描述:你刚刚继承了流行的“破锣摇滚”乐队录制的尚未发表的N(1 <= N <= 20)首歌的版权。你打算从中精选一些歌曲,发行M(1 <= M <= 20)张CD。每一张CD最多可以容纳T(1 <= T <= 20)分钟的音乐,一首歌不能分装在两张CD中。不巧你是一位古典音乐迷,不懂如何判定这些歌的艺术价值。于是你决定根据以下标准进行选择:1.歌...

2018-03-01 16:38:29 121

原创 USACO-Section3.4 Electric Fences【数学】

题目描述:在本题中,格点是指横纵坐标皆为整数的点。为了圈养他的牛,农夫约翰建造了一个三角形的电网。他从原点(0,0)牵出一根通电的电线,连接格点(n,m)(0<=n<32000,0 < m<32000),再连接格点(p,0)(p>0),最后回到原点。牛可以在不碰到电网的情况下被放到电网内部的每一个格点上(十分苗条的牛)。如果一个格点碰到了电网,牛绝对不可以...

2018-03-01 00:09:45 317

hibernate5.2.12+spring5.0.2+tomcat8.5.23+ant1.10.3

该资源为hibernate5.2.12+spring5.0.2+tomcat8.5.23+ant1.10.3的整合,方便初学者搜索相关资源

2018-06-06

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除