小算法
fushenliao
Less is More
展开
-
vijos 1002 过河 (DP + 滚动数组 + 状态压缩)
描述在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧。在桥上有一些石子,青蛙很讨厌踩在这些石子上。由于桥的长度和青蛙一次跳过的距离都是正整数,我们可以把独木桥上青蛙可能到达的点看成数轴上的一串整点:0,1,……,L(其中L是桥的长度)。坐标为0的点表示桥的起点,坐标为L的点表示桥的终点。青蛙从桥的起点开始,不停的向终点方向跳跃。一次跳跃的距离是S到T之间的任意正整数(包括S,T)。当青蛙原创 2016-03-21 00:16:34 · 725 阅读 · 0 评论 -
一个比Manacher更快的最长回文子串算法
最长回文子串问题: 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度。回文就是正反读都是一样的字符串,如aba, abba等 求最长回文子串一个很著名的算法就是Manacher算法,时间复杂度为On。通常认为这是最优的算法。但今天我看到一个实测比Manacher跟快的算法,特来分享一下。 Manacher算法: char str2[maxn],原创 2017-02-05 21:40:17 · 394 阅读 · 0 评论 -
hdu 5938 Four Operations 模拟
Four Operations Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 210 Accepted Submission(s): 74 Problem Description Little Ruins原创 2016-10-30 16:51:34 · 402 阅读 · 0 评论 -
fzu 2041 Checker 枚举 模拟
Description Checker game is an interesting game. But now Bob is tired of playing with others, he wants to play by himself. The following are the rules of his games: 1. The chessboard is a straig原创 2016-10-16 23:19:49 · 448 阅读 · 0 评论 -
fzu 2038 Another Postman Problem 递归
Description Chinese Postman Problem is a very famous hard problem in graph theory. The problem is to find a shortest closed path or circuit that visits every edge of a (connected) undirected grap原创 2016-10-16 14:01:59 · 362 阅读 · 0 评论 -
poj 1042 Gone Fishing 枚举+贪心
Gone Fishing Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 33430 Accepted: 10232 Description John is going on a fishing trip. He has h hours available原创 2016-10-12 17:25:16 · 579 阅读 · 0 评论 -
Codeforces Round #378 (Div. 2) C. Epidemic in Monstropolis
C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There was an epidemic in Monstro原创 2016-11-03 00:42:07 · 351 阅读 · 0 评论 -
poj1019 Number Sequence 思维 递推
Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 38481 Accepted: 11166 Description A single positive integer i is given. Write a program t原创 2016-10-10 20:27:16 · 401 阅读 · 0 评论 -
Codeforces Round #361 (Div. 2) A. Mike and Cellphone
A. Mike and Cellphone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output While swimming at the beach, Mike has原创 2016-07-07 15:26:42 · 680 阅读 · 0 评论 -
任务执行顺序 (贪心)
有N个任务需要执行,第i个任务计算时占R[i]个空间,而后会释放一部分,最后储存计算结果需要占据O[i]个空间(O[i] < R[i])。原创 2016-05-22 23:59:57 · 645 阅读 · 0 评论 -
Huffman算法
Huffman采取的算法: 不断找到出现次数最少的两个“节点”合并,合并的新节点作为一个“大节点”——节点的频率是被合并两个节点的频率和。合并节点的过程相当于找一个节点作为两个被合并节点的父亲。原创 2016-05-21 16:17:21 · 987 阅读 · 0 评论 -
ZSC 1218 八进制小数
八进制小数可以用十进制小数精确的表示。比如,八进制里面的0.75等于十进制里面的0.963125 (7/8 + 5/64)。所有小数点后位数为n的八进制小数都可以表示成小数点后位数不多于3n的十进制小数。原创 2016-04-08 12:05:27 · 717 阅读 · 0 评论 -
HDU 1010 Tempter of the Bone (DFS + 奇偶剪枝)
DescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that原创 2016-02-28 19:39:49 · 310 阅读 · 0 评论 -
ZSC 1115 Cantor表 (水题)
Description 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的。他是用下面这一张表来证明这一命题的: Input 输入一个正整数N,1≤N≤10000000Output 表中的第N项Sample Input 7Sample Output 1/4虽然挺简单,但也有一些小技巧值得留意//#define Night_13 #include <iostream>原创 2016-02-25 23:28:15 · 591 阅读 · 0 评论 -
POJ 3273 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原创 2016-02-28 19:13:59 · 332 阅读 · 0 评论 -
poj 1001 Exponentiation 高精度乘法
Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 159384 Accepted: 38853 Description Problems involving the computation of exact values of ve原创 2016-08-13 17:56:56 · 421 阅读 · 0 评论 -
最近公共祖先 朴素 离线 在线 算法合集
描述 小Ho最近发现了一个神奇的网站!虽然还不够像58同城那样神奇,但这个网站仍然让小Ho乐在其中,但这是为什么呢? “为什么呢?”小Hi如是问道,在他的观察中小Ho已经沉迷这个网站一周之久了,甚至连他心爱的树玩具都弃置一边。 “嘿嘿,小Hi,你快过来看!”小Ho招呼道。 “你看,在这个对话框里输入我的名字,在另一个对话框里,输入你的名字,再点这个查询按钮,就可以查出来……什么!我们居然有原创 2017-02-17 17:27:26 · 1016 阅读 · 1 评论