自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

我の名字

年少不读书,竟打ACM

  • 博客(96)
  • 收藏
  • 关注

原创 食物链 POJ - 1182(并查集)

Problem Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述...

2019-08-16 16:53:50 107

原创 GCD and LCM HDU - 4497(质因数分解)

Problem DescriptionGiven two positive integers G and L, could you tell me how many solutions of (x,y,z)(x, y, z)(x,y,z) there are, satisfying that gcd(x,y,z)=Ggcd(x, y, z) = Ggcd(x,y,z)=G and lcm(x, ...

2019-08-14 08:23:35 258

原创 A/B HDU-1576(简单的数论题)

Problem Description要求(A/B)(A/B)(A/B)%997399739973,但由于A很大,我们只给出n(n=An(n=An(n=A%9973)9973)9973)(我们给定的AAA必能被BBB整除,且gcd(B,9973)=1)gcd(B,9973) = 1)gcd(B,9973)=1)。Input数据的第一行是一个 TTT,表示有 TTT 组数据。每组数据有两个数...

2019-08-13 10:03:47 194

原创 Prime Time UVA - 10200(精度处理,素数判定)

Problem DescriptionEuler is a well-known matematician, and, among many other things, he discovered that the formulan2+n+41n^{2} + n + 41n2+n+41 produces a prime for 0≤n<400 ≤ n < 400≤n...

2019-08-10 21:16:12 218

原创 Prim算法

最小生成树的Prim算法也是贪心算法的一大经典应用。Prim算法的特点是时刻维护一棵树,算法不断加边,加的过程始终是一棵树。Prim算法过程:一条边一条边地加, 维护一棵树。初始 E={}E ={}E={}空集合, V={V = {V={任意节点}}}循环 (n–1)(n – 1)(n–1) 次,每次选择一条边(v1,v2)(v1,v2)(v1,v2), 满足:v1v1v1 属于 V,v2...

2019-08-09 21:54:54 11939 4

原创 Help Hanzo LightOJ - 1197【素数筛,求区间素数个数】

Problem DescriptionAmakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he had a little problem with Hanzo Hattori, the best ninja and the love ...

2019-08-09 21:42:58 300

原创 Harmonic Number (II) LightOJ - 1245 (找规律)

Problem DescriptionI was trying to solve problem ‘1234 - Harmonic Number’, I wrote the following codelong long H( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) res = ...

2019-08-08 20:37:02 280

原创 推树过程

由前中序列求后序列座号123456前123456中324165从前序可以看出根节点为111根节点在中序的位置为444号,可以看出它的左右节点分别有333和222个;从前序列可以看出左333节点为(2,3,4)(2,3,4)(2,3,4),右2节点为(5,6)(5,6)(5,6),根节点的子节点为左:222,右:555;看下图:...

2019-08-08 15:02:44 851

原创 Trees on the level HDU - 1622(二叉树)

Problem DescriptionTrees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines’ CM-5 are based on fat trees. Quad- and octal-tree...

2019-08-08 14:58:18 307

原创 Binary Tree Traversals HDU - 1710(简单推树)

Problem DescriptionA binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most impor...

2019-08-08 14:36:47 184

原创 Elven Postman HDU - 5444 【二叉树查询节点,记录路径】

Problem DescriptionElves are very peculiar creatures. As we all know, they can live for a very long time and their magical prowess are not something to be taken lightly. Also, they live on trees. Ho...

2019-08-07 09:17:04 195

原创 【POJ - 3468】线段树的初步了解

线段树:{\color{Red} 线段树:}线段树:线段树是一种二叉搜索树,与区间树相似,它将一个区间划分成一些单元区间,每个单元区间对应线段树中的一个叶结点。使用线段树可以快速的查找某一个节点在若干条线段中出现的次数,时间复杂度为O(logN)O(logN)O(logN)。而未优化的空间复杂度为2N2N2N,实际应用时一般还要开4N4N4N的数组以免越界,因此有时需要离散化让空间压缩。定义...

2019-08-06 21:07:19 212

原创 敌兵布阵 HDU - 1166(线段树区间查找与更新)

ProblemDescription\mathfrak{Problem Description}ProblemDescriptionCCC国的死对头A国这段时间正在进行军事演习,所以CCC国间谍头子DerekDerekDerek和他手下TidyTidyTidy又开始忙乎了。AAA国在海岸线沿直线布置了NNN个工兵营地,DerekDerekDerek和Tidy的任务就是要监视这些工兵营地的活动情况...

2019-08-06 19:27:09 126

原创 HDU-1506 Largest Rectangle in a Histogram

Problem DescriptionA histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figur...

2019-08-06 17:37:14 121

原创 Tree Recovery UVA - 536(二叉树的遍历)

Problem DescriptionLittle Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes.This is an example of...

2019-08-06 10:54:42 176

原创 二叉树前中后的遍历

二叉树:{\color{Red} 二叉树:}二叉树:简单的介绍一下二叉树:二叉树是每个结点最多有两个子树的树结构。通常子树被称作“左子树”(left subtree)和“右子树”(right subtree)。二叉树常被用于实现二叉查找树和二叉堆。一棵深度为k,且有2k−12^{k}-12k−1个节点的二叉树,称为满二叉树。这种树的特点是每一层上的节点数都是最大节点数。而在一棵二叉树中,除最...

2019-08-06 00:12:22 184

原创 POJ - 2528【线段树+离散】Mayor's posters

ProblemDescription\mathfrak{Problem Description}ProblemDescriptionThe citizens of Bytetown, ABABAB, could not stand that the candidates in the mayoral election campaign have been placing their electo...

2019-08-05 12:14:21 177

原创 【线段树】A Simple Problem with Integers poj ——3468

A Simple Problem with IntegersYou have NNN integers, A1,A2,...,ANA1, A2, ... , ANA1,A2,...,AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each...

2019-08-05 09:47:04 140

原创 Cow Contest POJ - 3660 And Longest Paths UVA - 10000(弗洛伊德的应用)

N(1≤N≤100)N (1 ≤ N ≤ 100)N(1≤N≤100) cows, conveniently numbered 1..N1..N1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain cons...

2019-07-31 19:27:49 246

原创 Ice_cream's world I HDU - 2120(并查集,求环数)

Problem Descriptionice_cream’s world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wal...

2019-07-31 11:36:12 173

原创 A Walk Through the Forest HDU - 1142(最短路+记忆)

Problem DescriptionJimmy experiences a lot of stress at work these days, especially since his accident made working difficult. To relax after a hard day, he likes to walk home. To make things even ni...

2019-07-31 11:08:41 200

原创 最短路径的四种算法

最短路径四种算法1234FloydDijkstraBellman-Ford队列优化的Bellman-Ford一,只有四行的算法——Floyd-Warshall假设求顶点ViViVi到VjVjVj的最短路径。弗洛伊德算法依次找从ViViVi到VjVjVj,中间经过结点序号不大于000的最短路径,不大于111的最短路径,…直到中间顶点序号不大于n−1n-1n−1...

2019-07-30 19:42:49 15394 3

原创 find the longest of the shortest HDU - 1595(最短路径之记录路径)

Problem DescriptionMarica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she doesn’t live in the same city, she started preparing for the long journey.We know ...

2019-07-30 15:15:06 166

原创 I. Same String

Problem Description单点时限内存限制2.0 sec512 MB有两个只由小写字母组成的长度为nnn的字符串s1,s2s1,s2s1,s2和mmm组字母对应关系,每一组关系由两个字母c1c1c1和c2c2c2组成,代表c1c1c1可以直接变成c2c2c2,你需要判断s1s1s1是否可以通过这m组关系转换为s2s2s2。输入格式第一行输入一个n(1≤...

2019-07-28 19:04:59 150

原创 B. 恐怖的怪物(bfs搜索)

Problem Description单点时限内存限制5.0512MB一天早上,Dicer一觉醒来,发现自己来到了MineCraft的世界里面,身为MineCraft游戏爱好者的他欣喜不已,于是他在地下挖了一片长方体的空间作为秘密基地,可是他发现光照亮度小于等于777时,会有恐怖的怪物出现,并且他通过查阅资料发现光源方块产生光照每一米(方格)衰减111光照等级。此规...

2019-07-28 18:39:28 252

原创 Just Skip The Problem HDU - 6600

Problem DescriptionY_UME has just found a number xxx in his right pocket. The number is a non-negative integer ranging from 00 to 2n2^{n}2n−1 inclusively. You want to know the exact value of this num...

2019-07-28 17:26:48 180

原创 Roadblocks POJ - 3255(最短路中的次短路)

Problem DescriptionBessie has moved to a small farm and sometimes enjoys returning to visit one of her best friends. She does not want to get to her old home too quickly, because she likes the scener...

2019-07-28 17:01:11 149

原创 Advanced Fruits HDU - 1503

Problem DescriptionThe company “21st Century Fruits” has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times this method doesn’...

2019-07-28 16:34:12 568

原创 A,再战斐波那契

Problem Description单点时限1.0sec内存限制512MB小z 学会了斐波那契和gcdgcdgcd 后,老师又给他出了个难题,求第N个和第M个斐波那契数的最大公约数,这可难倒了小z ,不过在小z 的再三请求下,老师又告诉他了个条件,gcd(N,M)∈[1,90]gcd(N,M)∈[1,90]gcd(N,M)∈[1,90]。可是,笨拙的小z 还是不会,于是...

2019-07-27 21:39:20 144

原创 Space Elevator POJ - 2392 And Cash Machine POJ - 1276 (多重背包)

Problem DescriptionThe cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks w...

2019-07-23 00:03:44 165

原创 Bridging signals POJ - 1631 HDU - 1950 (最大上升子序列)

Problem Description’Oh no, they’ve done it again’, cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip c...

2019-07-22 21:49:30 130

原创 Alignment POJ - 1836

Problem DescriptionIn the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain. The captain is not satisfied w...

2019-07-22 21:26:46 151

原创 Pearls POJ - 1260(简单的dp)

Problem DescriptionIn Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pearl has its name because it delivers to the ...

2019-07-22 21:11:26 133

原创 HDU - 3466 Proud Merchants(排序背包问题)

Problem DescriptionRecently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still very p...

2019-07-22 20:52:22 193

原创 POJ - 1159 Palindrome (回文串与最长公共子序列问题)

Problem DescriptionA palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determi...

2019-07-22 10:47:24 250

原创 Zipper HDU - 1501 (DFS)一个搜索题

Problem DescriptionGiven three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitraril...

2019-07-22 09:35:36 195

原创 最大连续子序列 HDU - 1231

Problem Description给定K个整数的序列{ N1, N2, …, NK },其任意连续子序列可表示为{ Ni, Ni+1, …,Nj },其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个,例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和为20。...

2019-07-21 23:10:58 186

原创 Tempter of the Bone HDU - 1010(剪枝与搜索)

Problem DescriptionThe 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 rea...

2019-07-21 17:06:13 138

原创 A计划 HDU - 2102 (bfs搜索)

Problem Description可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位置用...

2019-07-21 16:33:45 117

原创 Sticks UVA - 307(剪枝技巧)

Problem DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 unitslong. Now he wants to return sticks to the original state, but he forgot how man...

2019-07-21 16:23:42 245

空空如也

空空如也

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

TA关注的人

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