算法
文章平均质量分 86
say_c_box
小白不能不努力~
展开
-
POJ1742——Coins 多重背包
原题如下:CoinsTime Limit: 3000MS Memory Limit: 30000KTotal Submissions: 32998 Accepted: 11214DescriptionPeople in Silverland use coins.They have coins of va原创 2016-03-15 17:57:06 · 605 阅读 · 0 评论 -
51NOD1125交换机器的最小代价(贪心算法)
原题如下:有N台机器重量各不相等,现在要求把这些机器按照重量排序,重量从左到右依次递增。移动机器只能做交换操作,但交换机器要花费一定的费用,费用的大小就是交换机器重量的和。例如:3 2 1,交换1 3后为递增排序,总的交换代价为4。给出N台机器的重量,求将所有机器变为有序的最小代价。(机器的重量均为正整数)Input第1行:1个数N,表示机器及房间的数量。(2 <= N <=原创 2016-02-17 12:34:17 · 2058 阅读 · 0 评论 -
ZOJ3844——Easy Task 模拟
原题如下:DescriptionYou are given n integers. Your task is very easy. You should find the maximum integer a and the minimum integer b among these nintegers. And then you should replace both a原创 2016-03-16 21:45:41 · 416 阅读 · 0 评论 -
Hdu 1394——Minimum Inversion Number 线段树应用(自己的详细分析)
Minimum Inversion NumberTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16258 Accepted Submission(s): 9890Problem Description原创 2016-03-31 14:44:14 · 363 阅读 · 0 评论 -
POJ 2139——Six Degrees of Cowvin Bacon 最短路径
原题如下:DescriptionThe cows have been making movies lately, so they are ready to play a variant of the famous game "Six Degrees of Kevin Bacon". The game works like this: each cow is consider原创 2016-03-20 21:40:40 · 391 阅读 · 0 评论 -
POJ 3259——Wormholes 图论
原题如下DescriptionWhile 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 desti原创 2016-03-21 08:28:39 · 337 阅读 · 0 评论 -
HDU2577——How to Type 动态规划
题目如下:DescriptionPirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After testing for several days, she finds that i原创 2016-03-16 21:58:57 · 527 阅读 · 0 评论 -
ZOJ3609——数论基础 扩展欧几里得求解乘法逆元
原题如下:DescriptionThe modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x (mod m). This is equivalent toax≡1 (mod m).InputThere are原创 2016-03-24 13:11:45 · 504 阅读 · 0 评论 -
POJ2524——Ubiquitous Religions 并查集基础
并查集的基础应用题目如下:DescriptionThere are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different reli原创 2016-03-14 20:56:11 · 443 阅读 · 0 评论 -
POJ1611——The Suspects 并查集基础
又一道并查集基础题题目如下:The SuspectsTime Limit: 1000MS Memory Limit: 20000KTotal Submissions: 30194 Accepted: 14684DescriptionSevere acute respiratory syndrom原创 2016-03-14 21:10:44 · 604 阅读 · 0 评论 -
POJ2236——Wireless Network 并查集应用
题目如下:Wireless NetworkTime Limit: 10000MS Memory Limit: 65536KTotal Submissions: 21254 Accepted: 8937DescriptionAn earthquake takes place in Southeast Asia原创 2016-03-15 08:59:17 · 502 阅读 · 0 评论 -
POJ1703——Find them, Catch them 并查集应用
Find them, Catch themTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 39239 Accepted: 12059DescriptionThe police office in Tadu City decides to say ends原创 2016-03-15 09:27:46 · 694 阅读 · 0 评论 -
51NOD 1449——砝码称重(贪心算法)
题目如下:现在有好多种砝码,他们的重量是 w0,w1,w2,... 每种各一个。问用这些砝码能不能表示一个重量为m的东西。样例解释:可以将重物和3放到一个托盘中,9和1放到另外一个托盘中。Input单组测试数据。第一行有两个整数w,m (2 ≤ w ≤ 10^9, 1 ≤ m ≤ 10^9)。Output如果能,输出YES原创 2016-03-15 12:25:36 · 2221 阅读 · 0 评论 -
51NOD——1191 消灭兔子 (可用优先队列解决的贪心算法)
51NOD贪心算法那个分类下,有几道题目都可以用优先队列解决。贴出来大家一起学习下。其余两题传送门: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1163 http://www.51nod.com/onlineJudge/questionCode.ht原创 2016-03-15 12:43:03 · 783 阅读 · 0 评论 -
51NOD——1117 聪明的木匠(可用优先队列解决的贪心算法)
该题来自POJ3253另外两道可用优先队列解决的贪心算法:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1163http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1191原题如下:一位老木匠需要将一根长的木棒切成原创 2016-03-15 12:56:19 · 700 阅读 · 0 评论 -
51NOD 1163——最高的奖励(可用优先队列解决的贪心问题)
类似问题传送门: 消灭兔子 聪明的木匠原题如下:有N个任务,每个任务有一个最晚结束时间以及一个对应的奖励。在结束时间之前完成该任务,就可以获得对应的奖励。完成每一个任务所需的时间都是1个单位时间。有时候完成所有任务是不可能的,因为时间上可能会有冲突,这需要你来取舍。求能够获得的最高奖励。Input第1行:一个数N,表示任务的数量(2原创 2016-03-15 15:56:18 · 954 阅读 · 0 评论 -
Codeforces Round #364 (Div. 2)(A,B,C,D) 题解
PS:水平有限(惭愧脸)比赛的时候只写了前四题。剩下的等会写了再更新= =E貌似也不难,但还没调对。A. Cardstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard out原创 2016-07-23 10:51:56 · 1461 阅读 · 0 评论 -
CodeForces 699B——One Bomb(预处理,暴力枚举)
C - One BombTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionYou are given a description of a depot. It is a rectangular check原创 2016-07-23 12:15:29 · 814 阅读 · 0 评论 -
CodeForces 698A——Vacations(动态规划)
D - VacationsTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionVasya has n days of vacations! So he decided to improve his IT s原创 2016-07-23 12:59:34 · 1394 阅读 · 0 评论 -
POJ 2342 ——Anniversary party(树形dp基础)
Anniversary partyTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionThere is going to be a party to celebrate the 80-th Anniversa原创 2016-07-23 13:13:36 · 279 阅读 · 0 评论 -
HDU 4445 ——Crazy Tank(数学题,暴力枚举)
Crazy TankTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionCrazy Tank was a famous game about ten years ago. Every child liked原创 2016-07-23 13:18:22 · 537 阅读 · 0 评论 -
CodeForces 697C——Lorenzo Von Matterhorn(二叉树,map)
C. Lorenzo Von Matterhorntime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBarney lives in NYC. NYC has infin原创 2016-07-23 13:26:14 · 395 阅读 · 0 评论 -
CodeForces 699D—— Fix a Tree(并查集判断环)
D. Fix a Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is an undirected connected graph witho原创 2016-07-23 13:35:39 · 1340 阅读 · 0 评论 -
POJ2559——Largest Rectangle in a Histogram(栈的应用)
Largest Rectangle in a HistogramTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 19094 Accepted: 6140DescriptionA histogram is a polygon composed of a原创 2016-07-24 11:23:07 · 350 阅读 · 0 评论 -
POJ3250——Bad Hair Day(栈的应用)
Bad Hair DayTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 17352 Accepted: 5846DescriptionSome of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a原创 2016-07-24 15:06:52 · 469 阅读 · 0 评论 -
POJ3221——Apple Tree(线段树,dfs序)
Apple TreeTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 25851 Accepted: 7665DescriptionThere is an apple tree outside of kaka's house. Every autumn,原创 2016-07-25 21:20:43 · 637 阅读 · 0 评论 -
HDU1542——Atlantis(扫描线,线段树,矩形面积并,离散化)
I - AtlantisTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 1542DescriptionThere are several ancient Greek texts that con原创 2016-07-25 21:27:57 · 373 阅读 · 0 评论 -
POJ3494——Largest Submatrix of All 1’s(栈的应用)
Largest Submatrix of All 1’sTime Limit: 5000MS Memory Limit: 131072KTotal Submissions: 5726 Accepted: 2150Case Time Limit: 2000MSDescriptionGiven a m-by-n原创 2016-07-24 16:28:16 · 510 阅读 · 0 评论 -
POJ3668——Frequent values(线段树,RMQ,ST表)
Frequent valuesTime Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit Status Practice POJ 3368DescriptionYou are given a sequence of n integers a1 ,原创 2016-07-25 22:17:55 · 740 阅读 · 0 评论 -
HDU2874——Connections between cities 详解 (LCA,RMQ,数据结构,dfs序,并查集)
Connections between citiesTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9013 Accepted Submission(s): 2178Problem Description原创 2016-07-26 11:53:55 · 1681 阅读 · 0 评论 -
Bribe the Prisoners——GCJ 2009 Round1C C(区间dp)
题目:P个并排的牢房(1,2,3....P)。每个牢房一个囚犯。现在要释放其中的Q个囚犯。每释放一个囚犯,就得向左给每一个相邻囚犯一枚金币,直到遇到空牢房。向右也是如此。问以什么样的顺序释放所花费的金币最少?#include #include #include #include #include #include #include #include #include usin原创 2016-07-17 10:17:42 · 483 阅读 · 0 评论 -
POJ 2718——穷竭搜索,全排列生成
题目:Smallest DifferenceTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8100 Accepted: 2221DescriptionGiven a number of distinct decimal digits, y原创 2016-07-17 10:52:53 · 383 阅读 · 0 评论 -
POJ 3050——Hopscotch(dfs,爆搜)
题目:HopscotchTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3239 Accepted: 2245DescriptionThe cows play the child's game of hopscotch in a non-t原创 2016-07-17 11:35:39 · 284 阅读 · 0 评论 -
POJ2393————Yogurt factory (贪心)
题目如下:Yogurt factoryTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9225 Accepted: 4695DescriptionThe cows have purchased a yogurt factory that makes原创 2016-07-17 14:21:33 · 378 阅读 · 0 评论 -
POJ1127——Jack Straws(计算几何,直线相交)
Jack StrawsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4059 Accepted: 1836DescriptionIn the game of Jack Straws, a number of plastic or wooden "st原创 2016-07-28 12:21:05 · 390 阅读 · 0 评论 -
POJ2398——Coneology(计算几何,扫描线)
ConeologyTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 3771 Accepted: 739DescriptionA student named Round Square loved to play with cones. He would原创 2016-07-28 13:50:42 · 360 阅读 · 0 评论 -
CodeForces 266C—— Below the Diagonal(模拟,贪心,递归)
题目:D - Below the DiagonalTime Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionYou are given a square matrix consisting o原创 2016-07-18 20:32:16 · 820 阅读 · 0 评论 -
ACdream 1187 ——Rational Number Tree(二进制,递归)
题目:DescriptionConsider an infinite complete binary tree where the root node is 1/1 and left and right childs of node p/q are p/(p+q) and (p+q)/q, respectively. This tree looks like:原创 2016-07-18 20:52:48 · 435 阅读 · 0 评论 -
HDU 4311 ——Meeting point-1(暴力)
题目:A - Meeting point-1Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionIt has been ten years since TJU-ACM established. And i原创 2016-07-18 21:15:30 · 309 阅读 · 0 评论 -
HDU4609——3-idiots(FFT求卷积,留着以后学)
转载自kuangbin巨巨,还不懂,以后学FFT求卷积转载 2016-07-18 21:23:16 · 286 阅读 · 0 评论