HDOJ
文章平均质量分 84
--Simone-
这个作者很懒,什么都没留下…
展开
-
Eliminate the Conflict(2 - sat)
icts are everywhere in the world, from the young to the elderly, from families to countries. Conflicts cause quarrels, fights or even wars. How wonderful the world will be if all conflicts can be eliminated.Edward contributes his lifetime to invent a 'Conf原创 2014-12-04 16:16:25 · 120 阅读 · 0 评论 -
Tr A(矩阵快速幂)
Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。 Input数据的第一行是一个T,表示有T组数据。每组数据的第一行有n(2 <= n <= 10)和k(2 <= k < 10^9)两个数据。接下来有n行,每行有n个数据,每个数据的范围是[0,9],表示方阵A的内容。 Output对应每组数据,输出Tr(A^k)%9973。 Sample Input22 21原创 2014-07-30 23:20:04 · 56 阅读 · 0 评论 -
A Simple Math Problem(矩阵快速幂)
now is thinking about a simple function f(x).If x < 10 f(x) = x.If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);And ai(0<=i<=9) can only be 0 or 1 .Now, I will give a0 ~ a9 and two positive integers原创 2014-07-30 22:48:55 · 166 阅读 · 0 评论 -
Wow! Such Sequence!(线段树)
, Doge got a funny birthday present from his new friend, Protein Tiger from St. Beeze College. No, not cactuses. It's a mysterious blackbox.After some research, Doge found that the box is maintaining a sequence an of n numbers internally, initially all num原创 2014-07-29 22:09:41 · 54 阅读 · 0 评论 -
Yet Another Multiple Problem(BFS)
nThere are tons of problems about integer multiples. Despite the fact that the topic is not original, the content is highly challenging. That’s why we call it “Yet Another Multiple Problem”.In this problem, you’re asked to solve the following question: G原创 2014-07-28 21:54:09 · 74 阅读 · 0 评论 -
覆盖的面积(线段树 + 扫描线 + 离散化)
原创 2014-07-26 12:26:20 · 56 阅读 · 0 评论 -
Atlantis(线段树 + 扫描线 + 离散化)
the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe different regions of Atlantis. Your friend Bill has to know the total area for which maps exist. You (unwisely) volunteered to原创 2014-07-25 23:18:19 · 57 阅读 · 0 评论 -
Picture(线段树 + 扫描线 + 离散化)
the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered by the others. The length of the boundary of the union of all rectangles is called the perimeter. Write a program to calcul原创 2014-07-25 17:49:00 · 58 阅读 · 0 评论 -
Man Down(线段树 + 区间覆盖 + DP)
n 100 floors” is an famous and interesting game.You can enjoy the game from http://hi.baidu.com/abcdxyzk/blog/item/16398781b4f2a5d1bd3e1eed.htmlWe take a simplified version of this game. We have only two kinds of planks. One kind of the planks contains fo原创 2014-07-25 10:10:53 · 117 阅读 · 0 评论 -
Memory Control(线段树 + vector + 区间合并)
are numbered from 1 up to N.A sequence of memory units is called a memory block. The memory control system we consider now has four kinds of operations:1. Reset Reset all memory units free.2. New x Allocate a memory block consisted of x continuous free原创 2014-07-24 14:46:03 · 112 阅读 · 0 评论 -
Tunnel Warfare(线段树 + 区间合并)
ar of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except the two at the ends, every village was directly connected with two ne原创 2014-07-23 23:59:39 · 46 阅读 · 0 评论 -
Alice and Bob(贪心 + multiset)
's game never ends. Today, they introduce a new game. In this game, both of them have N different rectangular cards respectively. Alice wants to use his cards to cover Bob's. The card A can cover the card B if the height of A is not smaller than B and the原创 2014-07-23 14:20:19 · 96 阅读 · 0 评论 -
Task(贪心)
m tasks to complete. The ith task need xi minutes to complete. Meanwhile, this task has a difficulty level yi. The machine whose level below this task’s level yi cannot complete this task. If the company completes this task, they will get (500*xi+2*yi) dol原创 2014-07-23 12:57:00 · 93 阅读 · 0 评论 -
Just a Hook(线段树 + 延迟标记)
DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.Now Pudge wants to do some operations on the hook.Let us number the consecutive me原创 2014-07-19 15:34:43 · 45 阅读 · 0 评论 -
Stars(树状数组)
points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the stars. For example, loo原创 2014-05-26 00:12:36 · 117 阅读 · 0 评论 -
敌兵布阵(树状数组)
原创 2014-05-25 13:57:32 · 54 阅读 · 0 评论 -
Queuing(矩阵快速幂)
ty Queues are data structures which are known to most computer scientists. The Queue occurs often in our daily life. There are many people lined up at the lunch time. Now we define that ‘f’ is short for female and ‘m’ is short for male. If the queue’s l原创 2014-07-31 11:46:30 · 84 阅读 · 0 评论 -
Kiki & Little Kiki 2(矩阵快速幂)
ere are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n) is the light k-1.At time of 0, some of them turn on, and others turn off. Change the state of light i (if it's on, turn off原创 2014-08-04 12:31:15 · 65 阅读 · 0 评论 -
Monkey and Banana(DP)
f researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monkey is clever enough, it shall be able to reach the banana by plac原创 2014-08-06 13:53:56 · 39 阅读 · 0 评论 -
Beam Cannon(线段树 + 扫描线)
alaxies broke out Star Wars. Each planet is warring for resources. In the Star Wars, Planet X is under attack by other planets. Now, a large wave of enemy spaceships is approaching. There is a very large Beam Cannon on the Planet X, and it is very powerful原创 2014-11-04 16:10:30 · 143 阅读 · 0 评论 -
Game with Pearls(二分图)
are playing a game with tubes and pearls. The rule of the game is:1) Tom and Jerry come up together with a number K. 2) Tom provides N tubes. Within each tube, there are several pearls. The number of pearls in each tube is at least 1 and at most N. 3) Jer原创 2014-11-03 18:04:01 · 50 阅读 · 0 评论 -
Battle ships(二分图)
ow you are an excellent navy commander, who is responsible of a tough mission currently. Your fleet unfortunately encountered an enemy fleet near the South Pole where the geographical conditions are negative for both sides. The floating ice and iceberg blo原创 2014-11-02 19:33:09 · 123 阅读 · 0 评论 -
Qin Shi Huang's National Road System(最小生成树 + LCA)
scriptionDuring the Warring States Period of ancient China(476 BC to 221 BC), there were seven kingdoms in China ---- they were Qi, Chu, Yan, Han, Zhao, Wei and Qin. Ying Zheng was the king of the kingdom Qin. Through 9 years of wars, he finally conquere原创 2014-11-02 11:33:20 · 110 阅读 · 0 评论 -
Coprime(容斥定理 + 筛选)
standing in a line. Each of them has a unique id number.Now the Ragnarok is coming. We should choose 3 people to defend the evil. As a group, the 3 people should be able to communicate. They are able to communicate if and only if their id numbers are pairw原创 2014-10-28 20:36:45 · 64 阅读 · 0 评论 -
Connections between cities(LCA + 并查集)
After World War X, a lot of cities have been seriously damaged, and we need to rebuild those cities. However, some materials needed can only be produced in certain places. So we need to transport these materials from city to city. For most of roads had be原创 2014-10-02 14:21:27 · 113 阅读 · 0 评论 -
How far away ?(LCA 在线算法RMQ)
n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want to go from house A to house B"? Usually it hard to answer. But luckily int this village the answer is alwa原创 2014-10-02 13:01:21 · 70 阅读 · 0 评论 -
Explosion(bitset 优化的传递闭包 + 概率)
t enjoys playing games very much. Now, he is playing such a game. There are N rooms, each with one door. There are some keys(could be none) in each room corresponding to some doors among these N doors. Every key can open only one door. Matt has some bombs,原创 2014-09-23 15:59:24 · 85 阅读 · 0 评论 -
Saving Tang Monk(BFS)
o the West》(also 《Monkey》) is one of the Four Great Classical Novels of Chinese literature. It was written by Wu Cheng'en during the Ming Dynasty. In this novel, Monkey King Sun Wukong, pig Zhu Bajie and Sha Wujing, escorted Tang Monk to India to get sacre原创 2014-09-23 15:09:20 · 281 阅读 · 0 评论 -
233 Matrix(矩阵快速幂)
we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 2333, 23333... (it means a0,1 = 233,a0原创 2014-09-16 19:55:40 · 93 阅读 · 0 评论 -
Number Sequence(二进制)
There is a special number sequence which has n+1 integers. For each number in sequence, we have two rules: ● ai ∈ [0,n] ● ai ≠ aj( i ≠ j ) For sequence a and sequence b, the integrating degree t is defined as follows(“⊕” denotes exclusive or):t = (a0 ⊕原创 2014-09-15 19:17:28 · 59 阅读 · 0 评论 -
Dice(BFS)
ices on the table. On each face of the dice, a distinct number was written. Consider a1.a2,a3,a4,a5,a6 to be numbers written on top face, bottom face, left face, right face, front face and back face of dice A. Similarly, consider b1.b2,b3,b4,b5,b6 to be nu原创 2014-09-15 19:05:59 · 72 阅读 · 0 评论 -
Walk(概率DP)
think I could be anything, but now I know that I couldn't do anything. So I started traveling.The nation looks like a connected bidirectional graph, and I am randomly walking on it. It means when I am at node i, I will travel to an adjacent node with the原创 2014-09-15 18:59:16 · 56 阅读 · 0 评论 -
Fast Matrix Calculation(矩阵快速幂)
y, Alice and Bob felt bored again, Bob knows Alice is a girl who loves math and is just learning something about matrix, so he decided to make a crazy problem for her.Bob has a six-faced dice which has numbers 0, 1, 2, 3, 4 and 5 on each face. At first, he原创 2014-08-19 17:12:42 · 154 阅读 · 0 评论 -
Fighting the Landlords(模拟)
hting the Landlords is a card game which has been a heat for years in China. The game goes with the 54 poker cards for 3 players, where the “Landlord” has 20 cards and the other two (the “Farmers”) have 17. The Landlord wins if he/she has no cards left, an原创 2014-08-08 12:19:02 · 107 阅读 · 0 评论 -
最大连续子序列(DP)
定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个, 例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和 为20。 在今年的数据结构考卷中,要求编写程序得到最大和,现在增加一个要求,即还需要输出该 子序列的第一个和最后一个元素。原创 2014-05-24 11:02:19 · 54 阅读 · 0 评论 -
Humble Numbers(技巧)
ose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers. Write a program to find and print the nth element in this sequence原创 2014-05-24 10:06:21 · 87 阅读 · 0 评论 -
Eddy's 洗牌问题(规律)
个ACMer,他不仅喜欢做ACM题,而且对于纸牌也有一定的研究,他在无聊时研究发现,如果他有2N张牌,编号为1,2,3..n,n+1,..2n。这也是最初的牌的顺序。通过一次洗牌可以把牌的序列变为n+1,1,n+2,2,n+3,3,n+4,4..2n,n。那么可以证明,对于任意自然数N,都可以在经过M次洗牌后第一次重新得到初始的顺序。编程对于小于100000的自然数N,求出M的值。 Input每行一个整数N Output输出与之对应的M Sample Inp原创 2014-05-24 09:08:43 · 320 阅读 · 0 评论 -
Billboard(线段树)
to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest programming competitions, changes in the dining room menu, and other imp原创 2013-09-01 20:40:38 · 60 阅读 · 0 评论 -
Minimum Inversion Number(线段树 or 技巧统计)
he inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj.For a given sequence of numbers a1, a2, ..., an, if we move the first m >= 0 numbers to the end of the seqenc原创 2013-08-28 17:29:58 · 56 阅读 · 0 评论 -
I Hate It(线段树)
原创 2013-08-26 18:31:47 · 54 阅读 · 0 评论