
POJ题目小练
针对POJ(北京大学程序在线评测系统)上的一些算法练习题,提供个人的一些思路与解法
BYSora
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
poj3321——Apple Tree(树上树状数组)
DescriptionThere is an apple tree outside of kaka’s house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.The tre原创 2017-05-03 20:53:40 · 1340 阅读 · 0 评论 -
poj1658——Eva's Problem
DescriptionEva的家庭作业里有很多数列填空练习。填空练习的要求是:已知数列的前四项,填出第五项。因为已经知道这些数列只可能是等差或等比数列,她决定写一个程序来完成这些练习。 Input第一行是数列的数目t(0 <= t <= 20)。以下每行均包含四个整数,表示数列的前四项。约定数列的前五项均为不大于10^5的自然数,等比数列的比值也是自然数。 Output对输入的每个数列,输出它的原创 2017-05-03 15:11:06 · 1576 阅读 · 0 评论 -
poj1664——放苹果(递推)
Description把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。 Input第一行是测试数据的数目t(0 <= t <= 20)。以下每行均包含二个整数M和N,以空格分开。1<=M,N<=10。 Output对输入的每组数据M和N,用一行输出相应的K。 Sample Input1 7 3 Sampl原创 2017-05-03 15:02:26 · 1741 阅读 · 0 评论 -
poj1552——Doubles
DescriptionAs part of an arithmetic competency program, your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in each list原创 2017-05-03 14:42:10 · 2041 阅读 · 0 评论 -
poj1163——The Triangle(简单dp)
Description7 3 8 8 1 0 2 7 4 4 4 5 2 6 5(Figure 1) Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at原创 2017-05-03 11:39:34 · 1124 阅读 · 0 评论 -
poj2528——Mayor's posters(离散化+区间覆盖)
DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has原创 2017-05-03 09:46:06 · 1191 阅读 · 0 评论 -
poj3308——Paratroopers(最小割)
DescriptionIt is year 2500 A.D. and there is a terrible war between the forces of the Earth and the Mars. Recently, the commanders of the Earth are informed by their spies that the invaders of Mars wan原创 2017-05-02 20:03:14 · 2217 阅读 · 0 评论 -
poj3318——Matrix Multiplication(随机化算法)
DescriptionYou are given three n × n matrices A, B and C. Does the equation A × B = C hold true?InputThe first line of input contains a positive integer n (n ≤ 500) followed by the the three matrices A原创 2017-04-28 21:08:41 · 1428 阅读 · 0 评论 -
poj3177——Redundant Paths(双连通分量)
DescriptionIn order to get from one of the F (1 <= F <= 5,000) grazing fields (which are numbered 1..F) to another field, Bessie and the rest of the herd are forced to cross near the Tree of Rotten App原创 2017-04-28 20:22:26 · 1188 阅读 · 0 评论 -
poj3352——Road Construction(双连通分量)
DescriptionIt’s almost summer time, and that means that it’s almost summer construction time! This year, the good people who are in charge of the roads on the tropical island paradise of Remote Island原创 2017-04-28 20:19:47 · 1114 阅读 · 0 评论 -
poj1364——King(差分约束)
DescriptionOnce, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: “If my child was a son and if only he was a sound king.” After nine months her child was born,原创 2017-04-28 16:28:48 · 947 阅读 · 0 评论 -
poj2983——Is the Information Reliable?(差分约束+负权环路)
DescriptionThe galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line with N defense stations.原创 2017-04-26 16:56:02 · 969 阅读 · 0 评论 -
poj1201——Intervals(差分约束)
DescriptionYou are given n closed, integer intervals [ai, bi] and n integers c1, …, cn. Write a program that: reads the number of intervals, their end points and integers c1, …, cn from the standar原创 2017-04-26 16:07:47 · 674 阅读 · 0 评论 -
poj3096——Surprising Strings(STL)
DescriptionThe D-pairs of a string of letters are the ordered pairs of letters that are distance D from each other. A string is D-unique if all of its D-pairs are different. A string is surprising if i原创 2017-04-25 10:58:00 · 979 阅读 · 0 评论 -
poj1088——滑雪(记忆化dp)
DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813原创 2017-04-19 14:56:14 · 844 阅读 · 0 评论 -
poj2002——Squares(hash)
DescriptionA square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating about its centre by 90 degrees gives the same po原创 2017-04-11 18:15:50 · 1036 阅读 · 0 评论 -
poj1845——Sumdiv(数论+幂的因子和)
DescriptionConsider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901). InputThe only line contains the two n原创 2017-04-11 16:26:25 · 1006 阅读 · 0 评论 -
poj1011——Sticks(dfs+剪枝)
DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks h原创 2017-04-11 15:18:52 · 611 阅读 · 1 评论 -
poj1416——Shredding Company(dfs)
DescriptionYou have just been put in charge of developing a new shredder for the Shredding Company Although a “normal” shredder would just shred sheets of paper into little pieces so that the contents原创 2017-04-11 12:01:18 · 1125 阅读 · 0 评论 -
poj2342——Anniversary party(树形dp)
DescriptionThere 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原创 2017-03-31 21:24:33 · 603 阅读 · 0 评论 -
poj3070——Fibonacci(矩阵快速幂)
DescriptionIn the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …An alt原创 2017-03-29 16:52:23 · 977 阅读 · 0 评论 -
poj1942——Paths on a Grid(求阶乘)
DescriptionImagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastered years ago (this time he’s explaining that (a+b)2=a原创 2017-03-01 20:47:06 · 962 阅读 · 0 评论 -
poj2187——Beauty Contest(凸包+旋转卡壳)
DescriptionBessie, Farmer John’s prize cow, has just won first place in a bovine beauty contest, earning the title ‘Miss Cow World’. As a result, Bessie will make a tour of N (2 <= N <= 50,000) farms a原创 2017-02-26 19:41:30 · 850 阅读 · 0 评论 -
poj1113——Wall(凸包)
DescriptionOnce upon a time there was a greedy King who ordered his chief Architect to build a wall around the King’s castle. The King was so greedy, that he would not listen to his Architect’s proposa原创 2017-02-26 16:16:55 · 1309 阅读 · 0 评论 -
poj1852——Ants(模拟)
DescriptionAn army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two ants mee原创 2017-02-23 14:52:10 · 589 阅读 · 0 评论 -
poj3292——Semi-prime H-numbers(数论)
DescriptionThis problem is based on an exercise of David Hilbert, who pedagogically suggested that one study the theory of 4n+1 numbers. Here, we do only a bit of that.An H-number is a positive number原创 2017-02-18 21:15:30 · 1074 阅读 · 0 评论 -
poj2635——The Embarrassed Cryptographer(高精度取模)
DescriptionThe young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of users, which is now in use in his company. The cryptographic keys原创 2017-02-18 12:37:47 · 843 阅读 · 0 评论 -
poj2049——Finding Nemo(bfs)
DescriptionNemo is a naughty boy. One day he went into the deep sea all by himself. Unfortunately, he became lost and couldn’t find his way home. Therefore, he sent a signal to his father, Marlin, to a原创 2017-02-13 20:44:49 · 533 阅读 · 0 评论 -
poj2996——Help Me with the Game(模拟)
DescriptionYour task is to read a picture of a chessboard position and print it in the chess notation. InputThe input consists of an ASCII-art picture of a chessboard with chess pieces on positions de原创 2017-02-13 13:47:40 · 305 阅读 · 0 评论 -
poj1905——Expanding Rods(计算几何)
DescriptionWhen a thin rod of length L is heated n degrees, it expands to a new length L’=(1+n*C)*L, where C is the coefficient of heat expansion. When a thin rod is mounted on two solid walls and th原创 2017-02-12 17:02:55 · 663 阅读 · 0 评论 -
poj3273——Monthly Expense(二分)
DescriptionFarmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤ moneyi ≤ 10,0原创 2017-02-12 15:50:05 · 628 阅读 · 0 评论 -
poj1129——Channel Allocation(dfs)
DescriptionWhen a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receiver has a strong signal. However, the channels used by each repeat原创 2017-02-12 14:22:24 · 526 阅读 · 0 评论 -
poj2531——Network Saboteur(dfs)
DescriptionA university network is composed of N computers. System administrators gathered information on the traffic between nodes, and carefully divided the network into two subnetworks in order to m原创 2017-02-12 13:15:26 · 1619 阅读 · 0 评论 -
poj1442——Black Box(优先队列)
DescriptionOur Black Box represents a primitive database. It can save an integer array and has a special i variable. At the initial moment Black Box is empty and i equals 0. This Black Box processes a原创 2017-02-12 11:52:46 · 775 阅读 · 0 评论 -
poj1019——Number Sequence(数学)
DescriptionA single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2…Sk. Each group Sk consists of a sequence of positive i原创 2017-02-10 23:20:16 · 961 阅读 · 0 评论 -
poj3253——Fence Repair(哈夫曼)
DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length L原创 2017-02-10 21:04:19 · 706 阅读 · 0 评论 -
poj1840——Eqs(哈希)
DescriptionConsider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1原创 2017-02-10 18:17:08 · 745 阅读 · 0 评论 -
poj3687——Labeling Balls(拓扑排序)
DescriptionWindy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that:No two balls share the same label. The labeling satisfies several con原创 2017-02-10 16:54:26 · 1001 阅读 · 0 评论 -
poj3087——Shuffle'm Up(BFS)
DescriptionA common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C原创 2017-02-08 18:04:11 · 495 阅读 · 0 评论 -
poj2418——Hardwood Species(stl+map)
DescriptionHardwoods are the botanical group of trees that have broad leaves, produce a fruit or nut, and generally go dormant in the winter. America’s temperate climates produce forests with hundred原创 2017-01-21 15:12:29 · 776 阅读 · 0 评论