
ACM
文章平均质量分 61
细水会流长
个人博客:micsay.com,微信公众号:micsaycom
展开
-
HDU 5723 Abandoned country [最小生成树+dfs]
题干Problem Description An abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since abandoned for a long time, the roads need to be re-built. There are m(m≤1000000) roads to be r原创 2016-07-22 19:33:30 · 266 阅读 · 0 评论 -
后缀数组
这里是罗老师的讲解,我认为够详细了。 用后缀数组解字符串子串问题,要先理清楚SA数组,Rank数组,Height数组的真正含义,再将某个问题的答案用这三个数组表达出来,有时候可能要加上自己另外构造的辅助数组,公式写出来了,就成功了一半。原创 2016-07-30 11:33:04 · 227 阅读 · 0 评论 -
HDU 5726 GCD [RMQ+二分]
题干链接:走你题解/***@author micsay*先用RMQ预处理各个区间的gcd,然后再用二分法+map统计相同gcd区间的区间个数*具体解题思路请看注释**/#include<cstdio>#include<cmath>#include<cstring>#include<map>//构建mp数组的函数int _func(int a,int b){ if(!a)ret原创 2016-07-20 11:49:38 · 259 阅读 · 0 评论 -
Acm踩过的坑
定义数组的时候,比如int array[3]={0,1,2,3},就算array[0]不用,也不要定义成了int array[3]={1,2,3}认真读题,不是所有的输入输入都明确表明了输入数据的数据类型,不是所有的数都默认是整数,万一输入数据是double就坑了认真读题,如果给出了一个范围,比如给你一个连续的整数,也不一定是从小到大或者从大到小,一定做好判断才行未完待续原创 2016-07-13 11:09:31 · 1047 阅读 · 0 评论 -
HDU 4597 Play Game[博弈论 负值最大函数 记忆化搜索]
题干Problem Description Alice and Bob are playing a game. There are two piles of cards. There are N cards in each pile, and each card has a score. They take turns to pick up the top or bottom card from原创 2016-07-20 19:47:39 · 427 阅读 · 0 评论 -
POJ 1703 Find them, Catch them[并查集]
题干DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to iden原创 2016-07-21 11:14:05 · 292 阅读 · 0 评论 -
HDU 2639 Bone Collector II [动态规划 第k大01背包]
题干Problem Description The title of this problem is familiar,isn’t it?yeah,if you had took part in the “Rookie Cup” competition,you must have seem this title.If you haven’t seen it before,it doesn’t ma原创 2016-08-01 20:53:46 · 343 阅读 · 0 评论 -
POJ 2184 Cow Exhibition [动态规划 01背包]
??Description“Fat and docile, big and dumb, they look so stupid, they aren’t much fun…” - Cows with Guns by Dana Lyons The cows want to prove to the public that they are both smart and fun. In orde原创 2016-08-01 15:38:58 · 253 阅读 · 0 评论 -
poj动态规划经典题目
列表一:经典题目题号: 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740, 1742, 1887, 1926, 1936, 1952, 1953, 1转载 2016-08-03 23:46:07 · 919 阅读 · 0 评论 -
POJ 2533 最长上升子序列 [动态规划 + 二分搜索]
题干DescriptionA numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence (a1, a2, …, aN) be any sequence (ai1, ai2, …, aiK), where 1 <= i1 < i2 < … < iK <原创 2016-07-29 15:50:17 · 314 阅读 · 0 评论 -
HDU 5289 Assignment [RMQ区间查询+二分搜索]
题干hdu 5289走你题解/***RMQ区间查询+二分搜索**/#include<cstdio>#include<cmath>#include<algorithm>using namespace std;const int INF = 1e9;const int MAX = 100010;int root[MAX];int mpmax[MAX*2][65];int mpmin原创 2016-07-29 11:39:34 · 283 阅读 · 0 评论 -
POJ 3254 Corn Fields [动态规划 简单状态压缩]
题干DescriptionFarmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. R原创 2016-07-24 19:29:14 · 323 阅读 · 0 评论 -
ACM 求素数 线性筛法 o[n]
线性筛法,终于搞明白了,附带大神的讲解,走你const int N = 5000;int isNotPrime[N]={1,1};//0和1都不是素数,其他的取默认值0代表是素数int prime[N];//保存素数的数组int num_prime;//prime[]数组里面素数的个数,取默认值为0void init_prime(){ for(int i=2; i<N; i++){原创 2016-07-14 10:41:51 · 930 阅读 · 0 评论 -
HDU 1087 Super Jumping! Jumping! Jumping![动态规划——最大递增子序列]
之前做过最长递增子序列,这次碰到一个最大递增子序列,题意如下: 有一个跳跳棋棋盘,棋盘上面每个位置都有一个正数,你只能从左到右跳,每踩到一个位置,你的总分就加上该位置的数,一次可以跳一个或者多个,并且,你踩的数只能越踩越大 求最大你能得到的总分 状态转移公式如下: dp[i] = max{ dp[0],dp[1],....dp[j] } &&chess[max_pos]<chess[i]原创 2016-07-15 10:56:18 · 419 阅读 · 0 评论 -
HDU 1203 I NEED A OFFER![动态规划——01背包问题+简单概率]
题干Problem Description Speakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然要在他的经济承受范围内)。每个学校都有不同的申请费用a(万美元),并且Speakless估计了他原创 2016-07-15 11:13:57 · 436 阅读 · 0 评论 -
ACM[数论公式]
同余与模运算(a+b)mod n = ((a mod n)+(b mod n))mod n(a-b) mod n = ((a mod n)-(b mod n) + n)mod na*b mod n = (a mod n)(b mod n)mod n原创 2016-07-15 14:25:13 · 455 阅读 · 0 评论 -
HDU 1005 Number Sequence[数论]
题干Problem Description A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(n).Input The input原创 2016-07-15 17:02:00 · 291 阅读 · 0 评论 -
HDU 2062 Subset sequence[排列组合]
题干Problem Description Consider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in le原创 2016-07-16 20:39:07 · 272 阅读 · 0 评论 -
POJ 1837 Balance [动态规划——完全背包]
题干DescriptionGigel has a strange “balance” and he wants to poise it. Actually, the device is different from any other ordinary balance. It orders two arms of negligible weight and each arm’s length i原创 2016-07-16 11:17:05 · 350 阅读 · 1 评论 -
ACM 动态规划笔记
学习资源1.瞿老师给的动态规划题目以及讲解的链接:http://blog.jobbole.com/96364/2.解决动态规划问题,要先找出动态转移方程来,动态转移方程怎么找呢?首先得定好,用哪几个因子,可以明确的表示好一个状态,然后,再通过样例或者特例或者硬想,找出子问题和父问题的关系,或者说,子问题怎么push,可以影响到父问题?我感觉可以放开思路想,放心大胆的想,假设你不会动态规划,让你暴力搜原创 2016-07-13 11:13:23 · 4765 阅读 · 0 评论