ACM
分享ACM算法, 数据结构。
花雨就是花雨
最好的我还未等到~
展开
-
HDU2489--Minimal Ratio Tree(最小生成树)
Do more with lessDescription For a tree, which nodes and edges are all weighted, the ratio of it is calculated according to the following equation. Given a complete graph of n nodes with all原创 2017-08-14 19:00:29 · 409 阅读 · 0 评论 -
顺序表基本运算算法
//顺序表基本运算算法#include <stdio.h>#include <malloc.h>#define MaxSize 50typedef int ElemType; typedef struct { ElemType data[MaxSize]; //存放顺序表元素 int length; //存放顺序表的长度} SqLis原创 2017-09-08 17:53:41 · 4959 阅读 · 3 评论 -
数论模板
欧几里德算法(辗转相除法)int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b);}唯一分解定理int judge(int *x){ x[2] /= gec(x[2],x[1]); for(int i = 2; i <= k; i ++) x[2] /= gcd(x[i],x[2]);}扩展欧几里原创 2017-07-31 13:07:07 · 561 阅读 · 0 评论 -
UAa11582--Colossal Fibonacci Numbers!(快速幂)
Discussion The i’th Fibonacci number f(i) is recursively defined in the following way: •f(0)=0 f(0) = 0 andf(1)=1f(1) = 1 • f(i+2)=f(i+1)+f(i)f(i + 2) = f(i + 1) + f(i) for every i ≥ 0原创 2017-08-04 21:11:59 · 444 阅读 · 0 评论 -
HDU1577--WisKey的眼神(扩展欧几里德)
数论......原创 2017-05-25 17:35:48 · 455 阅读 · 0 评论 -
HDU3746--Cyclic Nacklace (Kmp)
Description CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinking原创 2017-06-14 17:54:09 · 539 阅读 · 0 评论 -
HDU1083--Courses(二分图最大匹配)
Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possible to form a committee of exactly P stu原创 2017-06-15 12:57:28 · 405 阅读 · 0 评论 -
HDU2188--选拔志愿者(巴什博弈)
Description 对于四川同胞遭受的灾难,全国人民纷纷伸出援助之手,几乎每个省市都派出了大量的救援人员,这其中包括抢险救灾的武警部队,治疗和防疫的医护人员,以及进行心理疏导的心理学专家。根据要求,我校也有一个奔赴灾区救灾的名额,由于广大师生报名踊跃,学校不得不进行选拔来决定最后的人选。经过多轮的考核,形势逐渐明朗,最后的名额将在“林队”和“徐队”之间产生。但是很巧合,2个人的简历几乎一模一原创 2017-07-29 10:07:42 · 641 阅读 · 0 评论 -
HDU4857--逃生(反向拓扑)
Problem Description 糟糕的事情发生啦,现在大家都忙着逃命。但是逃命的通道很窄,大家只能排成一行。 现在有n个人,从1标号到n。同时有一些奇怪的约束条件,每个都形如:a必须在b之前。 同时,社会是不平等的,这些人有的穷有的富。1号最富,2号第二富,以此类推。有钱人就贿赂负责人,所以他们有一些好处。 负责人现在可以安排大家排队的顺序,由于收了好处,所以他要让1号原创 2017-08-23 12:51:03 · 555 阅读 · 0 评论 -
HDU1257--最小拦截系统(贪心)
Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里原创 2017-08-31 17:47:55 · 303 阅读 · 0 评论 -
POJ2376--Cleaning Shifts(贪心)
贪心原创 2017-05-13 17:43:20 · 633 阅读 · 0 评论 -
POJ1700--Crossing River(贪心)
Do more with lessDescription A group of N people wishes to go across a river with only one boat, which can at most carry two persons. Therefore some sort of shuttle arrangement must be arranged in or原创 2017-05-14 21:02:19 · 488 阅读 · 0 评论 -
POJ1458--Common Subsequence(dp)
动态规划原创 2017-05-14 22:02:31 · 348 阅读 · 0 评论 -
POJ3624--Charm Bracelet(dp)
动态规划......原创 2017-05-14 22:15:55 · 439 阅读 · 0 评论 -
POJ2524--Ubiquitous Religions(并查集)
并查集......原创 2017-05-14 23:19:50 · 411 阅读 · 0 评论 -
POJ3579--Median(二分)
二分......原创 2017-05-15 12:00:23 · 403 阅读 · 0 评论 -
POJ2676--Sudoku(搜索)
搜索......原创 2017-05-15 21:54:34 · 287 阅读 · 0 评论 -
POJ1163--The Triangle数塔
动态规划......原创 2017-05-16 20:33:48 · 527 阅读 · 0 评论 -
POJ1088--滑雪(DP+搜索)
DP+搜索的简单组合原创 2017-05-31 14:26:43 · 422 阅读 · 0 评论 -
POJ2192--Zipper(dp)
Description Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but原创 2017-05-31 15:00:38 · 384 阅读 · 0 评论 -
POJ2586--Y2K Accounting Bug(贪心)
Discussion Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc. All what they remember is that MS Inc. posted a原创 2017-07-29 09:45:19 · 421 阅读 · 0 评论 -
POJ1789--Truck History(最小生成树)
Discussion Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each原创 2017-07-29 09:54:11 · 672 阅读 · 0 评论 -
POJ1067--取石子游戏(威佐夫博弈)
Discussion 有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。Input 输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非原创 2017-07-29 10:02:41 · 380 阅读 · 0 评论 -
POJ2975--Nin(Nin博弈)
Discussion Nim is a 2-player game featuring several piles of stones. Players alternate turns, and on his/her turn, a player’s move consists of removing one or more stones from any single pile. Play e原创 2017-07-29 10:36:54 · 514 阅读 · 0 评论 -
POJ1740--A New Stone Game(Nin变形)
Discussion Alice and Bob decide to play a new stone game.At the beginning of the game they pick n(1<=n<=10) piles of stones in a line. Alice and Bob move the stones in turn. At each step of the g原创 2017-07-29 11:59:40 · 515 阅读 · 0 评论 -
POJ3691--Sky Code(容斥)
Discussion Stancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft. That is why he is preparing to steal the spacecraft of Petru. There is only原创 2017-08-04 20:58:45 · 415 阅读 · 0 评论 -
POJ1753--Flip Game(枚举)
Do more with lessDescription Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each原创 2017-08-09 21:33:59 · 456 阅读 · 0 评论 -
POJ3259--Wormholes(SPFA)
Do more with lessDescription While 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 it原创 2017-08-23 10:38:12 · 430 阅读 · 0 评论 -
POJ3349--Snowflake Snow Snowflakes(哈希)
Do more with lessDescription You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Your program will read information about a原创 2017-08-23 16:47:30 · 494 阅读 · 1 评论 -
POJ2406--Power Strings(KMP变形)
Do more with lessDescription Given two strings a and b we define a*b to be their concatenation. For example, if a = “abc” and b = “def” then a*b = “abcdef”. If we think of concatenation as multiplica原创 2017-08-23 17:17:27 · 477 阅读 · 0 评论 -
POJ3295--Tautology(模拟)
Description WFF ‘N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s, t. A Well-formed formula (WFF) is any str原创 2017-09-03 18:19:56 · 361 阅读 · 0 评论 -
POJ2632--Crashing Robots(模拟)
Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is needed to ensure that the robots reach their destinations without crashing into each other. Of course, a原创 2017-09-03 21:18:24 · 358 阅读 · 0 评论 -
POJ1573--Robot Motion(模拟)
Description A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a grid. The possible instructions are原创 2017-09-04 17:59:35 · 363 阅读 · 0 评论