自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Godblessuam的博客

记录学习生活

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

原创 1045 Favorite Color Stripe-变种最长上升子序列

Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...

2019-12-06 20:00:35 152

原创 1073 Scientific Notation

Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [±][1-9].[0-9]+E[±][0-9]+ which means that the intege...

2019-11-18 20:24:27 140

原创 1067 Sort with Swap(0, i)

Given any permutation of the numbers {0, 1, 2,…, N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, ...

2019-11-14 17:38:21 137

原创 1053 Path of Equal Weight(DFS)

Given a non-empty tree with root R, and with weight W​i assigned to each tree node T​i. The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the path from R ...

2019-10-27 21:20:52 128

原创 1051 Pop Sequence(模拟栈)

Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the...

2019-10-27 19:48:39 164

原创 1064 Complete Binary Search Tree

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key.The right subt...

2019-10-22 19:20:18 246

原创 1043 Is It a Binary Search Tree

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key.The right subt...

2019-10-20 10:42:59 236

原创 1032 Sharing

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...

2019-09-26 20:30:43 72

原创 1031 Hello World for U

Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:h de ll rlowoThat is, the characters must be printed ...

2019-09-26 20:06:55 59

原创 1039 Course List for Student(注意范围)

Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes ...

2019-09-21 19:13:00 386

原创 1038 Recover the Smallest Number

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229...

2019-09-21 17:03:13 82

原创 1022 Digital Library(超简单方法)

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 number a...

2019-08-14 16:58:04 406

原创 1024 Palindromic Number

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 numbers...

2019-08-09 17:23:17 114

原创 1023 Have Fun with Numbers

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 number con...

2019-08-09 16:05:39 86

原创 PAT甲级-1015 Reversible Primes

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 also a pr...

2019-08-07 16:44:14 131

原创 PAT甲级-1017 Queueing at Bank

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 yellow li...

2019-08-07 16:38:48 182

原创 PAT甲级-1119 Pre- and Post-order Traversals

Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preorder and inorder ...

2019-05-23 17:11:16 149

原创 PAT甲级-1138 Postorder Traversal

Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...

2019-05-23 17:06:15 198

原创 PAT甲级-1151 LCA in a Binary Tree

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.Inpu...

2019-05-23 17:04:05 153

原创 超级玛丽-dfs

题目描述大家都知道" 超级玛丽" 是一个很善于跳跃的探险家,他的拿手好戏是跳跃,但它一次只能向前跳一步或两步。有一次,他要经过一条长为n的羊肠小道,小道中有m个陷阱,这些陷阱都位于整数位置,分别是a1,a2,…am,陷入其中则必死无疑。显然,如果有两个挨着的陷阱,则玛丽是无论如何也跳过不去的。现在给出小道的长度n,陷阱的个数及位置。求出玛丽从位置1开始,有多少种跳跃方法能到达胜利的彼岸(到达位...

2019-05-22 20:07:46 304

原创 贪吃的大嘴-动态规划

题目描述有一只特别贪吃的大嘴,她很喜欢吃一种小蛋糕,而每一个小蛋糕有一个美味度,而大嘴是很傲娇的,一定要吃美味度和刚好为m的小蛋糕,而且大嘴还特别懒,她希望通过吃数量最少的小蛋糕达到这个目的.所以她希望你能设计一个程序帮她决定要吃哪些小蛋糕.数据规模和约定m ≤ 20000,小蛋糕总数量≤50.输入先输入一行包含2个整数m、n,表示大嘴需要吃美味度和为m的小蛋糕,而小蛋糕一共有n种,...

2019-05-22 19:45:54 536

原创 开灯游戏-位运算

题目描述有9盏灯与9个开关,编号都是1~9。每个开关能控制若干盏灯,按下一次会改变其控制的灯的状态(亮的变成不亮,不亮变成亮的)。具体如下:第一个开关控制第二,第四盏灯;第二个开关控制第一,第三,第五盏灯;第三个开关控制第二,第六盏灯;第四个开关控制第一,第五,第七盏灯;第五个开关控制第二,第四,第六,第八盏灯;第六个开关控制第三,第五,第九盏灯;第七个开关控制第四,第八盏灯;...

2019-05-21 20:28:43 512

原创 有关子序列问题

最长公共子序列#include<iostream>#include<algorithm>#include<string>using namespace std;string a,b;int dp[1000][1000]; void cal_lcs()//计算最长公共子序列长度 { for(int i=1;i<=a.length();i++...

2019-05-21 15:53:38 149

原创 和最大子序列-分治

题目描述对于一个给定的长度为N的整数序列A,它的“子序列”的定义是:A中非空的一段连续的元素(整数)。你要完成的任务是,在所有可能的子序列中,找到一个子序列,该子序列中所有元素的和是最大的(跟其他所有子序列相比)。程序要求你输出这个最大值。输入输入文件的第一行包含一个整数N,第二行包含N个整数,表示A。其中1 < = N < = 100000-10000 <...

2019-05-20 20:46:45 1040

转载 3000米排名预测-dfs+模拟

题目描述3000米长跑时,围观党们兴高采烈地预测着 最后的排名。因为他们来自不同的班,对所有运动员不一定都了解,于是他们分别对自己了解的一些运动员的实力作出了评估,即对部分运动员做了相对排名的预 测,并且告诉了可怜留守的班长。因为无聊,于是他们就组团去打Dota去了。比赛结束后他们向班长询问最后的排名,但班长不记得了,只记得他们中哪些人的 预测是正确的,哪些人的预测是错误的。他们想知道比赛...

2019-05-20 20:00:30 168

原创 自写大数运算(加,乘,阶乘)

矩阵乘法#include<iostream>#include<cstring>#define maxn 35using namespace std;struct Matrix{ int matrix[maxn][maxn];};int n,m;Matrix mx;Matrix mul(Matrix a,Matrix b){ Matrix res; ...

2019-05-20 15:55:35 147

原创 搭积木-蓝桥

小明对搭积木非常感兴趣。他的积木都是同样大小的正立方体。在搭积木时,小明选取 m 块积木作为地基,将他们在桌子上一字排开,中间不留空隙,并称其为第0层。随后,小明可以在上面摆放第1层,第2层,……,最多摆放至第n层。摆放积木必须遵循三条规则:规则1:每块积木必须紧挨着放置在某一块积木的正上方,与其下一层的积木对齐;规则2:同一层中的积木必须连续摆放,中间不能留有空隙;规则3:小明不喜欢的...

2019-05-19 15:53:11 283

原创 2n皇后问题

题目描述给定一个n*n的棋盘,棋盘中有一些位置不能放皇后。现在要向棋盘中放入n个黑皇后和n个白皇后,使任意的两个黑皇后都不在同一行、同一列或同一条对角线上,任意的两个白皇后都不在同一行、同一列或同一条对角线上。问总共有多少种放法?n小于等于8。输入输入的第一行为一个整数n,表示棋盘的大小。接下来n行,每行n个0或1的整数,如果一个整数为1,表示对应的位置可以放皇后,如果一个整数为0,表示对...

2019-05-18 21:08:36 1132

原创 最大子阵-蓝桥

题目描述给定一个n*m的矩阵A,求A中的一个非空子矩阵,使这个子矩阵中的元素和最大。其中,A的子矩阵指在A中行和列均连续的一块。样例说明取最后一列,和为10。数据规模和约定对于100%的数据,1< =n, m< =500,A中每个元素的绝对值不超过5000。输入输入的第一行包含两个整数n, m,分别表示矩阵A的行数和列数。接下来n行,每行m个整数,表示矩阵A。输...

2019-05-18 16:26:08 1262

原创 带分数-蓝桥杯

题目描述100 可以表示为带分数的形式:100 = 3 + 69258 / 714。还可以表示为:100 = 82 + 3546 / 197。注意特征:带分数中,数字1~9分别出现且只出现一次(不包含0)。类似这样的带分数,100 有 11 种表示法。输入从标准输入读入一个正整数N (N< 1000*1000)输出程序输出该数字用数码1~9不...

2019-05-18 10:45:14 561

原创 K进制数-dfs

题目描述考虑包含N位数字的K-进制数. 定义一个数有效, 如果其K-进制表示不包含两连续的0.考虑包含N位数字的K-进制数. 定义一个数有效, 如果其K-进制表示不包含两连续的0.例:1010230 是有效的7位数1000198 无效0001235 不是7位数, 而是4位数.给定两个数N和K, 要求计算包含N位数字的有效K-进制数的总数.假设2 <= K <= 10; ...

2019-05-18 09:39:28 512

原创 危险系数-蓝桥杯

问题描述抗日战争时期,冀中平原的地道战曾发挥重要作用。地道的多个站点间有通道连接,形成了庞大的网络。但也有隐患,当敌人发现了某个站点后,其它站点间可能因此会失去联系。我们来定义一个危险系数DF(x,y):对于两个站点x和y (x != y), 如果能找到一个站点z,当z被敌人破坏后,x和y不连通,那么我们称z为关于x,y的关键点。相应的,对于任意一对站点x和y,危险系数DF(x,y...

2019-05-16 17:46:08 432

原创 地宫取宝-蓝桥杯

题目描述X 国王有一个地宫宝库。是 n x m 个格子的矩阵。每个格子放一件宝贝。每个宝贝贴着价值标签。地宫的入口在左上角,出口在右下角。小明被带到地宫的入口,国王要求他只能向右或向下行走。走过某个格子时,如果那个格子中的宝贝价值比小明手中任意宝贝价值都大,小明就可以拿起它(当然,也可以不拿)。当小明走到出口时,如果他手中的宝贝恰好是k件,则这些宝贝就可以送给小明。请你帮小明...

2019-05-16 16:27:17 902

原创 Lattice Points-欧拉函数

A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x, y) does not pass throug...

2019-05-15 10:59:56 777

原创 wormholes-spfa算法求负环路

While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that i...

2019-05-15 10:02:31 117

原创 watchcow-欧拉回路

Bessie’s been appointed the new watch-cow for the farm. Every night, it’s her job to walk across the farm and make sure that no evildoers are doing any evil. She begins at the barn, makes her patrol, ...

2019-05-14 14:43:29 137

原创 caoao's bridges-tarjan算法求割边

Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But he wouldn’t give up. Caocao’s army still was not good at water battles, so he came up with another idea. He built many island...

2019-05-14 10:30:18 261

原创 敌兵布阵-树状数组

C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。中央情报局要研究敌人究竟演习什么战术,所以...

2019-05-13 18:44:44 115

原创 A Simple Problem with Integers-线段树模板(入门)

You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the su...

2019-05-13 18:38:38 1475 3

原创 合根植物-蓝桥

题目描述w星球的一个种植园,被分成 m * n 个小格子(东西方向m行,南北方向n列)。每个格子里种了一株合根植物。这种植物有个特点,它的根可能会沿着南北或东西方向伸展,从而与另一个格子的植物合成为一体。如果我们告诉你哪些小格子间出现了连根现象,你能说出这个园中一共有多少株合根植物吗?输入第一行,两个整数m,n,用空格分开,表示格子的行数、列数(1<m,n<1000)。接...

2019-05-11 20:02:23 263

空空如也

空空如也

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

TA关注的人

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