hdu3065 ac自动机
摘要:病毒侵袭持续中Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4809Accepted Submission(s): 1698 Problem Description小t非常感谢大家帮忙解决了他的上一个问题。然而病毒侵袭持续中。在小t的不懈努力下,他发现了网路中的“万恶之源”。这是一个庞大的病毒网站,他有着好多好多的病毒,但是这个网站包含的病毒很奇怪,这些病毒的特征码很短,而且只包含“英文大写字符”。当然小t好想好想为民除害,但是小t从来不打
阅读全文
posted @
2013-08-23 22:33
ERKE
阅读(260)
推荐(0)
hdu3695 ac自动机入门
摘要:Computer Virus on Planet PandoraTime Limit: 6000/2000 MS (Java/Others)Memory Limit: 256000/128000 K (Java/Others) Total Submission(s): 1846Accepted Submission(s): 510 Problem DescriptionAliens on planet Pandora also write computer programs like us. Their programs only consist of capital letters (‘A’
阅读全文
posted @
2013-08-23 19:43
ERKE
阅读(230)
推荐(0)
hdu2222 ac自动机入门
摘要:Keywords SearchTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 27138Accepted Submission(s): 8871 Problem DescriptionIn the modern time, Search engine came into the life of everybody like Google, Baidu, etc. Wiskey also wants to bring this feature
阅读全文
posted @
2013-08-23 18:54
ERKE
阅读(296)
推荐(0)
hdu4705 Y 2013 Multi-University Training Contest 10
摘要:YTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 304Accepted Submission(s): 104 Problem DescriptionSample Input41 21 31 4Sample Output1Hint1. The only set is {2,3,4}.2. Please use #pragma comment(linker, "/STACK:16777216")一定要构个无向图,不构无向
阅读全文
posted @
2013-08-23 00:37
ERKE
阅读(314)
推荐(0)
hdu4704 Sum 2013 Multi-University Training Contest 10 数论题
摘要:SumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 127Accepted Submission(s): 60 Problem DescriptionSample Input2Sample Output2解题思路:很容易看得出,这是个组合数学的插板问题,答案为2^(n-1);由于n特别大,则(2^(n-1))%1000000007=(2^((n-1)%1000000006))%1000000007;因为1000000007为素数,设为p
阅读全文
posted @
2013-08-22 19:03
ERKE
阅读(415)
推荐(0)
hdu4686 Arc of Dream 2013 Multi-University Training Contest 9矩阵快速幂
摘要:Arc of DreamTime Limit: 2000/2000 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 932Accepted Submission(s): 322 Problem DescriptionAn Arc of Dream is a curve defined by following function:where a0= A0 ai= ai-1*AX+AY b0= B0 bi= bi-1*BX+BY What is the value of AoD(N) mo
阅读全文
posted @
2013-08-21 17:26
ERKE
阅读(313)
推荐(0)
hdu2157矩阵快速幂
摘要:How many ways??Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 954 Accepted Submission(s): 314 Problem Description春天到了, HDU校园里开满了花, 姹紫嫣红, 非常美丽. 葱头是个爱花的人, 看着校花校草竞相开放, 漫步校园, 心情也变得舒畅. 为了多看看这迷人的校园, 葱头决定, 每次上课都走不同的路线去教室, 但是由于时间问题, 每次只能经过k个地方, 比方说, 这..
阅读全文
posted @
2013-08-21 15:44
ERKE
阅读(193)
推荐(0)
十大矩阵经典题目(转)
摘要:好像目前还没有这方面题目的总结。这几天连续看到四个问这类题目的人,今天在这里简单写一下。这里我们不介绍其它有关矩阵的知识,只介绍矩阵乘法和相关性质。 不要以为数学中的矩阵也是黑色屏幕上不断变化的绿色字符。在数学中,一个矩阵说穿了就是一个二维数组。一个n行m列的矩阵可以乘以一个m行p列的矩阵,得到的结果是一个n行p列的矩阵,其中的第i行第j列位置上的数等于前一个矩阵第i行上的m个数与后一个矩阵第j列上的m个数对应相乘后所有m个乘积的和。比如,下面的算式表示一个2行2列的矩阵乘以2行3列的矩阵,其结果是一个2行3列的矩阵。其中,结果的那个4等于2*2+0*1: 下面的算式则是一个1 x 3的矩阵.
阅读全文
posted @
2013-08-21 15:24
ERKE
阅读(900)
推荐(0)
poj3070矩阵快速幂
摘要:FibonacciTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 7752Accepted: 5501DescriptionIn 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 alternative formul
阅读全文
posted @
2013-08-21 15:13
ERKE
阅读(154)
推荐(0)
矩阵快速幂(可做模板用)
摘要:矩阵的快速幂是用来高效地计算矩阵的高次方的。将朴素的o(n)的时间复杂度,降到log(n)。这里先对原理(主要运用了矩阵乘法的结合律)做下简单形象的介绍:一般一个矩阵的n次方,我们会通过连乘n-1次来得到它的n次幂。但做下简单的改进就能减少连乘的次数,方法如下:把n个矩阵进行两两分组,比如:A*A*A*A*A*A => (A*A)*(A*A)*(A*A)这样变的好处是,你只需要计算一次A*A,然后将结果(A*A)连乘自己两次就能得到A^6,即(A*A)^3=A^6。算一下发现这次一共乘了3次,少于原来的5次。其实大家还可以取A^3作为一个基本单位。原理都一样:利用矩阵乘法的结合律,来减少
阅读全文
posted @
2013-08-21 14:30
ERKE
阅读(360)
推荐(0)
uva12519
摘要:The Farnsworth Parabox Professor Farnsworth, a renowned scientist that lives in year 3000 working at Planet Express Inc., performed a failed experiment that nearly killed him. As a sub-product, some strange boxes were created. Farnsworth gave one of the boxes to Leela, who accidentally discovered ..
阅读全文
posted @
2013-08-17 20:10
ERKE
阅读(253)
推荐(0)
hdu1760博弈SG
摘要:A New Tetris GameTime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 929Accepted Submission(s): 422 Problem Description曾经,Lele和他姐姐最喜欢,玩得最久的游戏就是俄罗斯方块(Tetris)了。 渐渐得,Lele发觉,玩这个游戏只需要手快而已,几乎不用经过大脑思考。 所以,Lele想出一个新的玩法。Lele和姐姐先拿出一块长方形的棋盘,这个棋盘有些格子是不可用的,剩下的都是可用
阅读全文
posted @
2013-08-16 22:06
ERKE
阅读(350)
推荐(0)
hdu1524博弈SG
摘要:A Chess GameTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1100 Accepted Submission(s): 504 Problem DescriptionLet's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same p
阅读全文
posted @
2013-08-16 20:18
ERKE
阅读(258)
推荐(0)
hdu1356&hdu1944 博弈论的SG值(王道)
摘要:S-NimProblem DescriptionArthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows:The starting position has a number of heaps, all containing some, not necessarily equal, number of beads.The players take turns chosing a heap and removing a positive.
阅读全文
posted @
2013-08-16 14:22
ERKE
阅读(288)
推荐(0)
博弈论(转) 挺好的
摘要:以下是我从网上收集的关于组合博弈的资料汇总:有一种很有意思的游戏,就是有物体若干堆,可以是火柴棍或是围棋子等等均可。两个人轮流从堆中取物体若干,规定最后取光物体者取胜。这是我国民间很古老的一个游戏,别看这游戏极其简单,却蕴含着深刻的数学原理。下面我们来分析一下要如何才能够取胜。(一)巴什博奕(Bash Game):只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。 显然,如果n=m+1,那么由于一次最多只能取m个,所以,无论先取者拿走多少个,后取者都能够一次拿走剩余的物品,后者取胜。因此我们发现了如何取胜的法则:如果n=(m+1)r+s,(r为任意.
阅读全文
posted @
2013-08-16 11:01
ERKE
阅读(188)
推荐(0)
hdu4678 Mine 2013 Multi-University Training Contest 8 博弈题
摘要:MineTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 352 Accepted Submission(s): 94 Problem DescriptionHave you ever played a game in Windows: Mine? This game is played on a n*m board, just like the Pic(1) On the board, Under some grids there ar..
阅读全文
posted @
2013-08-16 00:33
ERKE
阅读(489)
推荐(0)
hdu1671字典树
摘要:Phone ListTime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7343Accepted Submission(s): 2525 Problem DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone ca
阅读全文
posted @
2013-08-15 10:34
ERKE
阅读(125)
推荐(0)
hdu1251字典树递归算法
摘要:统计难题Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 131070/65535 K (Java/Others) Total Submission(s): 13831Accepted Submission(s): 5938 Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatiu
阅读全文
posted @
2013-08-15 09:29
ERKE
阅读(280)
推荐(0)
poj2337欧拉回路要求输出路径
摘要:CatenymsTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 8368Accepted: 2202DescriptionA catenym is a pair of words separated by a period such that the last letter of the first word is the same as the last letter of the second. For example, the following are catenyms:dog.gopher gopher.rat ra.
阅读全文
posted @
2013-08-15 00:43
ERKE
阅读(257)
推荐(0)
凸包(转)
摘要:转再出处 http://www.cnblogs.com/Booble/转载请注明出处 http://www.cnblogs.com/Booble/[Poj 1113] 计算几何之凸包(一) {卷包裹算法}{半个寒假都在写凸包这几篇文章整理一下主要介绍 二维凸包的求解算法以及一个简单的应用}====================================================================一.凸集&凸包(下文中所有的集合 若不作特殊说明 都是指欧氏空间上的集合)凸集(Convex Set):任意两点的连线都在这个集合内的集合就是一个凸集.A set i
阅读全文
posted @
2013-08-14 19:51
ERKE
阅读(373)
推荐(0)
hdu1116有向图判断欧拉通路判断
摘要:Play on WordsTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4263Accepted Submission(s): 1384 Problem DescriptionSome of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Becau
阅读全文
posted @
2013-08-14 17:20
ERKE
阅读(739)
推荐(0)
hdu3018欧拉回路题
摘要:Ant TripTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1107Accepted Submission(s): 404 Problem DescriptionAnt Country consist of N towns.There are M roads connecting the towns.Ant Tony,together with his friends,wants to go through every part of t
阅读全文
posted @
2013-08-14 15:58
ERKE
阅读(168)
推荐(0)
hdu1878判断欧拉回路
摘要:欧拉回路Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8186Accepted Submission(s): 2926 Problem Description欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个图,问是否存在欧拉回路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是节点数N ( 1 2 #include 3 #include 4 #include 5 ...
阅读全文
posted @
2013-08-14 15:14
ERKE
阅读(180)
推荐(0)
poj2823一道纯单调队列
摘要:Sliding WindowTime Limit: 12000MSMemory Limit: 65536KTotal Submissions: 32099Accepted: 9526Case Time Limit: 5000MSDescriptionAn array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers
阅读全文
posted @
2013-08-14 14:03
ERKE
阅读(119)
推荐(0)
poj2891非互质同余方程
摘要:Strange Way to Express IntegersTime Limit: 1000MSMemory Limit: 131072KTotal Submissions: 8176Accepted: 2439DescriptionElina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following:Choose k different positive integers
阅读全文
posted @
2013-08-14 13:59
ERKE
阅读(264)
推荐(0)
poj1006中国剩余定理
摘要:BiorhythmsTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 103506Accepted: 31995DescriptionSome people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have perio
阅读全文
posted @
2013-08-14 13:55
ERKE
阅读(175)
推荐(0)
poj1014二进制优化多重背包
摘要:DividingTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 53029Accepted: 13506DescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value
阅读全文
posted @
2013-08-14 13:52
ERKE
阅读(178)
推荐(0)
poj3264RMQ
摘要:Balanced LineupTime Limit: 5000MSMemory Limit: 65536KTotal Submissions: 28835Accepted: 13579Case Time Limit: 2000MSDescriptionFor the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with som
阅读全文
posted @
2013-08-14 13:07
ERKE
阅读(157)
推荐(0)
hdu1556树状数组的区间更新单点查询
摘要:Color the ballTime Limit: 9000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6084Accepted Submission(s): 3227 Problem DescriptionN个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int a[1000000]; ...
阅读全文
posted @
2013-08-14 13:04
ERKE
阅读(166)
推荐(0)
hdu1698线段树的区间更新区间查询
摘要:Just a HookTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13001Accepted Submission(s): 6476 Problem DescriptionIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several conse
阅读全文
posted @
2013-08-14 13:02
ERKE
阅读(237)
推荐(0)
hdu1754线段树的单点更新区间查询
摘要:I Hate ItTime Limit: 9000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 27606Accepted Submission(s): 10956 Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束
阅读全文
posted @
2013-08-14 12:56
ERKE
阅读(247)
推荐(0)
hdu3729二分匹配
摘要:I'm Telling the TruthTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1033Accepted Submission(s): 510 Problem DescriptionAfter this year’s college-entrance exam, the teacher did a survey in his class on students’ score. There are n students in
阅读全文
posted @
2013-08-14 12:52
ERKE
阅读(305)
推荐(0)
hdu4632
摘要:Palindrome subsequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/65535 K (Java/Others) Total Submission(s): 1538Accepted Submission(s): 635 Problem DescriptionIn mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without chang
阅读全文
posted @
2013-08-14 12:49
ERKE
阅读(205)
推荐(0)
poj1067威佐夫博奕
摘要:取石子游戏Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 31490Accepted: 10374Description有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大
阅读全文
posted @
2013-08-14 12:37
ERKE
阅读(144)
推荐(0)
poj3468树状数组的区间更新,区间求和
摘要:A Simple Problem with IntegersTime Limit: 5000MSMemory Limit: 131072KTotal Submissions: 47174Accepted: 13844Case Time Limit: 2000MSDescriptionYou 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 g.
阅读全文
posted @
2013-08-14 09:02
ERKE
阅读(564)
推荐(0)
poj2155一个二维树状数组
摘要:MatrixTime Limit: 3000MSMemory Limit: 65536KTotal Submissions: 15125Accepted: 5683DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 2 #include 3 #include 4 #include 5 #include 6 using n...
阅读全文
posted @
2013-08-14 08:53
ERKE
阅读(158)
推荐(0)
hdu3756三分基础题
摘要:Dome of CircusTime Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 937 Accepted Submission(s): 420 Special JudgeProblem DescriptionA travelling circus faces a tough challenge in designing the dome for its performances. The circus has a number of show
阅读全文
posted @
2013-08-14 08:49
ERKE
阅读(232)
推荐(0)
CodeForces 242E二维线段树
摘要:E. XOR on SegmentYou've got an array a, consisting of n integers a1, a2, ..., an. You are allowed to perform two operations on this array:Calculate the sum of current array elements on the segment [l, r], that is, count value al + al + 1 + ... + ar.Apply the xor operation with a given number x t
阅读全文
posted @
2013-08-14 08:38
ERKE
阅读(320)
推荐(0)
树形DP
摘要:列出一些经典问题吧:1:给出一棵树 每个节点有权值 要求父节点和子节点不能同时取 求能够取得的最大值 (hdu1520)2:给出一棵树,求离每个节点最远的点的距离 (hdu2196)3:1>在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。求获得尽量多的宝物应该攻克哪M个城堡。 (hdu1561)题解:树形dp+背包 2>每个节点有两个值bug和brain,当清扫该节点的所有bug时就得到brain值,只有当父节点被清空时,才可以清扫它的子节点,而清
阅读全文
posted @
2013-08-08 22:37
ERKE
阅读(300)
推荐(0)
二分匹配题集
摘要:普通匹配,多重匹配 【HDU】1068 Girls and Boys 最大匹配★1150 Machine Schedule 最小点覆盖★1151 Air Raid 最小路径覆盖★1179 Ollivanders 最大匹配★1281 棋盘游戏 行列匹配+求关键点★★1498 50 years, 50 colors 行列匹配★1507 Uncle Tom's Inherited Land* 黑白染色+奇偶匹配(1X2的矩形覆盖)★1528 Card Game Cheater 最大匹配★1845 Jimmy’s Assignment 最大匹配(HK算法)★2063 过山车 最大匹配★2119
阅读全文
posted @
2013-08-06 21:41
ERKE
阅读(167)
推荐(0)