- 博客(60)
- 收藏
- 关注
原创 Makefile编写初级
Makefile定义了一套规则,规定了哪些文件哪些需要优先编译,哪些需要后编译,哪些需要重新编译。Makedile完成之后整个工程只需要一个make命令便可以完成全部编译工作。完成编译,链接等各种功能。Makefile的基本规则是:目标 :依赖(tab)规则目标:需要生成的目标文件以来:生成该目标所需要的文件tab:每条规则必须以tab键开头,不能使用空格规则:由依赖文件生成目标文件的具体方式例:demo : demo.cppgcc demo.cpp -o dem
2021-09-13 15:04:56 262
原创 线段树初级
线段树的基本概念与应用 1. 线段树是一颗二叉搜索树,它的每个结点存储的是一个区间的信息。 2. 线段树的存储是以结构体的形式进行的,每个结点需包含所维护区间的左,右端点, 区间所需维护的信息。 3. 使用线段树可以快速的查询所需信息,它的时间复杂度为O(logN),而未优化的空间复 杂度为2N...
2018-12-10 21:24:52 165
原创 Line
A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018inclusive, or to find out that su...
2018-09-02 20:26:05 245
原创 整数划分
将N分为若干个不同整数的和,有多少种不同的划分方式,例如:n = 6,{6} {1,5} {2,4} {1,2,3},共4种。由于数据较大,输出Mod 10^9 + 7的结果即可。Input输入1个数N(1 <= N <= 50000)。Output输出划分的数量Mod 10^9 + 7。Sample Input6Sample Output4思路...
2018-09-02 20:24:31 166
原创 Maximum GCD
Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possible pair of these integers.InputThe first line of input is an integer N (1 < N < 100) that det...
2018-09-02 20:23:09 323
原创 Harmonic Number
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:In this problem, you are given n, you have to find Hn.InputInput starts with an integer T...
2018-09-02 20:19:52 483
原创 Goldbach`s Conjecture
Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:Every even integer, greater than 2, can be expressed as the sum of two primes [1]....
2018-09-02 20:16:06 198
原创 位操作
假设你工作在一个32位的机器上,你需要将某一个外设寄存器的第X位设置成0(最低位为第0位,最高位为第31位),将第Y位开始的连续三位设置成110(从高位到低位的顺序),而其他位保持不变。对给定的寄存器值R,及X,Y,编程计算更改后的寄存器值R。Input仅一行,包括R,X,Y,以逗号","分隔,R为16进制表示的32位整数,X,Y在0-31之间且Y>=3,(Y-X)的绝对值>=...
2018-08-26 20:17:42 265
原创 Anniversary party
There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tr...
2018-08-26 20:14:52 131
原创 S-Trees
A Strange Tree (S-tree) over the variable set Xn = {x1,x2,...,xn} is a binary tree representing a Boolean function f:{0,1}->{0,1}. Each path of the S-tree begins at the root node and consists of n+...
2018-08-26 20:09:42 180
原创 度度熊学队列
度度熊正在学习双端队列,他对其翻转和合并产生了很大的兴趣。 初始时有 NN 个空的双端队列(编号为 11 到 NN ),你要支持度度熊的 QQ 次操作。 ①11 uu ww valval 在编号为 uu 的队列里加入一个权值为 valval 的元素。(w=0w=0 表示加在最前面,w=1w=1 表示加在最后面)。 ②22 uu ww 询问编号为 uu 的队列里的某个元素并删除它。( w=0w...
2018-08-26 20:06:54 123
原创 The Falling Leaves
Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on the trees, followed quickly by the falling leaves accumulating under the trees. If the same thing ha...
2018-08-26 20:03:26 122
原创 Tree
You are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of the binary tree to any leaf. The value of a path is the sum o...
2018-08-26 19:57:44 108
原创 Not so Mobile
Before being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. This kind of mobile is usually found hanging over cradles of small...
2018-08-26 19:53:24 103
原创 The order of a Tree
As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1. insert a key k to a empty tree, then the tree become a tree with only one node; ...
2018-08-26 19:48:35 101
原创 Trees on the level
Trees 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-trees are fundamental to...
2018-08-26 19:46:49 188
原创 二叉搜索树
判断两序列是否为同一二叉搜索树序列Input开始一个数n,(1<=n<=20) 表示有n个需要判断,n= 0 的时候输入结束。 接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树。 接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树。Output如果序列相同则...
2018-08-26 19:35:33 110
原创 Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arr...
2018-08-19 20:24:54 123
原创 Mr. Kitayuta's Colorful Graph
Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color ci, connecting vertex a...
2018-08-19 17:30:21 138
原创 Tree Recovery
Little 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 one of her creati...
2018-08-19 17:25:19 149
原创 HDU Today
经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强。这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬浦镇陶姚村买了个房子,开始安度晚年了。 这样住了一段时间,徐总对当地的交通还是不太了解。有时很郁闷,想去一个地方又不知道应该乘什么公交车,在什么地方转车,在什么地方下车(其实徐总自己有车,却一定要与...
2018-08-16 21:11:25 127
原创 Slim Span
Given an undirected weighted graph G, you should find one of spanning trees specified as follows.The graph G is an ordered pair (V, E), where V is a set of vertices {v1, v2, …, vn} and E is a set of...
2018-08-16 21:07:05 115
原创 Minimum Transport Cost
These are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivered from one city to another. The transpor...
2018-08-16 17:11:26 137
原创 Parity
你的朋友写下一串包含1和0的串让你猜,你可以从中选择一个连续的子串(例如其中的第3到第5个数字)问他,该子串中包含了奇数个还是偶数个1,他会回答你的问题,然后你可以继续提问......你怀疑朋友的答案可能有错,或说同他之前的答案相互矛盾,例如:1 - 2 奇数,3 - 4 奇数,那么可以确定1 - 4 一定是偶数,如果你的朋友回答是奇数,就产生了矛盾。给出所有你朋友的答案,请你找出第一个出现矛盾的...
2018-08-16 17:05:01 198
原创 Ice_cream's world I
ice_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 wall between watchtower...
2018-08-16 17:02:13 167
原创 Wormholes
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...
2018-08-14 16:33:54 100
原创 Play on Words
Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very impo...
2018-08-14 16:31:49 91
原创 确定比赛名次
有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。 Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N表...
2018-08-14 16:17:20 188
原创 六度分离
1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人就可以将他们联系在一起,因此他的理论也被称为“六度分离”理论(six degrees of separation)。虽然米尔格兰姆的理论屡屡应验,一直也有很多社会学家对其兴趣浓厚,但是在30多年的时间...
2018-08-14 16:15:15 561
原创 最短路径问题
给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。Input输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点。n和m为0时输入结束。 (1<n<=1000, 0<m&...
2018-08-14 16:09:58 156
原创 数组的最大代价
数组A包含N个元素A1, A2......AN。数组B包含N个元素B1, B2......BN。并且数组A中的每一个元素Ai,都满足1 <= Ai <= Bi。数组A的代价定义如下: (公式表示所有两个相邻元素的差的绝对值之和)给出数组B,计算可能的最大代价S。Input第1行:1个数N,表示数组的长度(1 <= N <= 50000)。 第...
2018-08-09 17:05:24 125
原创 Is It A Tree?
A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties. There ...
2018-08-09 16:59:49 133
原创 小希的迷宫
上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给你,让你帮忙判断她的...
2018-08-09 16:56:47 140
原创 食物链
动物王国中有三类动物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个动物,用上述两种说法,一句接一句地说出K句话,...
2018-08-09 16:52:41 938
原创 Largest Rectangle in a Histogram
A 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 figure on the left shows ...
2018-08-05 20:19:03 138
原创 FATE
最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s只怪。请问他能升掉这最后一级吗?Inp...
2018-08-05 17:41:13 118
原创 Greatest Common Increasing Subsequence
This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence.InputEach sequence is described with M - its length (1 <= M <= 500) and M integer numbers...
2018-08-05 17:37:55 201
原创 搬寝室
搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3号楼,因为10号要封楼了.看着寝室里的n件物品,xhd开始发呆,因为n是一个小于2000的整数,实在是太多了,于是xhd决定随便搬2*k件过去就行了.但还是会很累,因为2*k也不小是一个不大于n的整数.幸运的是xhd根据多年的搬东西的经验发现每搬一次的疲劳度是和左右手的物品的重量差的平方成正比(这里补充...
2018-08-05 17:22:54 98
原创 Two Strings Swaps
You are given two strings aa and bb consisting of lowercase English letters, both of length nn. The characters of both strings have indices from 11 to nn, inclusive.You are allowed to do the followi...
2018-08-02 20:11:20 204
原创 Space Elevator
The 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 with which to build t...
2018-08-02 15:44:45 637
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人