经典题型
yamatsui
这个作者很懒,什么都没留下…
展开
-
HDU 1080 Human Gene Functions
最长公共子序列的变形。。。。。。。看了别人的题解终于明白怎么回事了,果然动态规划博大精深。 这是题源 以下是代码: #include <iostream> #include <cstdio> #include <map> #include <algorithm> #include <cstring> #include <string...原创 2019-04-13 00:13:05 · 145 阅读 · 0 评论 -
STL6-----J - Passing the Message
来源hdu3410 这道题让我发现了单调栈的唯一性,即可以使得数组记录的位置不会重复。 代码如下: #include <iostream> #include <stack> #include <cstdio> #include <algorithm> #include <cstring> #define mem(a,b) memset (...原创 2019-04-09 22:18:20 · 130 阅读 · 0 评论 -
STL6----K - Light Bulb
zoj3203 这道题对精度的要求很高。 #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; const double MAX = 1e4; const double ESP = 1e-10; double H...原创 2019-04-09 23:49:38 · 130 阅读 · 0 评论 -
poj 1651 Multiplication Puzzle
题源 区间dp dp[i][j]表示区间i到j的最小值,而i<k<j,表示最后选择第k个数的情况 代码如下: #include <iostream> #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; const ll MAX = 1000...原创 2019-04-13 14:37:11 · 111 阅读 · 0 评论 -
hdu 1394 Minimum Inversion Number
题源 这道题的思路是先建立一颗空树,各个节点均为零,假设读入num[i],则num[i]只需要询问i+1到 n-1有多少小于num[i]的数,然后累加即可,这样就转化为了区间操作。 这道题还用到一个结论,那就是0~n组成的序列中,把第一个数移到最后一个,逆序树先减少该数的值,再加上n-该数的值-1即为当前逆序数。 代码如下: #include <iostream> #include &...原创 2019-04-13 17:30:27 · 76 阅读 · 0 评论 -
斐波那契数列之矩阵快速幂
对于任意给出的n,给出斐波那契数列的第n项的后四位数 代码如下 #include <iostream> #include <cstdio> #include <algorithm> using namespace std; const long long MOD = 1e4; typedef long long ll; struct mat { long lo...原创 2019-04-13 21:33:41 · 122 阅读 · 0 评论 -
poj 2632 Crashing Robots
模拟题,考验一些细节的东西,但我真的是太笨了,细节方面总是出错。 这一题最关键的是如何用数组表示出这个二维坐标平面,我个人觉得把题目给的图顺时针旋转90度的话,就比较方便。 题源 以下是代码(虽然是从网上看的): #include <iostream> #include <algorithm> #include <cstdio> #include <map...原创 2019-04-25 18:55:13 · 176 阅读 · 0 评论 -
HDU 4704 Sum
这道题需要用快速幂,不过,因为n太大了,需要费马小定理来降幂。 然后,这题有个坑,题中没说,这里需要多组输入。 题源 #include <iostream> #include <cstdio> #include <algorithm> #include <string> using namespace std; typedef long long l...原创 2019-04-21 22:39:22 · 133 阅读 · 0 评论 -
STL6-------F - Largest Rectangle in a Histogram
一道单调栈的好题,充分说明了我只是明白了原理但是并不会应用。 这是题源poj2559 不过我发现要理解单调栈还是要有逆向思维啊 我也是看了大佬的博客才稍微明白了一些。 下面是代码; #include <iostream> #include <cstdio> #include <algorithm> #include <stack> #include ...转载 2019-04-09 19:53:30 · 142 阅读 · 0 评论 -
Traffic Light 考验思维的简单搜索
题目链接源自zoj 我的代码如下: #include <iostream> #include <cstdio> #include <queue> #include <cstring> using namespace std; struct node { int x, y, t; }; const int MAX = 1e6 + 1; int n, ...原创 2019-04-03 20:09:37 · 404 阅读 · 0 评论 -
hdu 1005
这是一道找规律的题,特点是可以暴力,但是数据比较大,会超时。 这时,很明显就是要找规律了,遇到这样的题,一般先用暴力来找出规律即可。 题源 #include <iostream> #include <cstdio> using namespace std; int num[50] = { 0 }; int main() { int A, B, n; num[1] = 1...原创 2019-04-11 18:20:42 · 149 阅读 · 0 评论 -
背包问题与简例
背包问题是动态规划中的经典问题,这里以洛谷上的一道题开心的金明为例,展示几种解法。 1.深度优先搜索(复杂度很高) #include &amp;lt;cstdio&amp;gt; #include &amp;lt;iostream&amp;gt; #include &amp;lt;vector&amp;gt; using namespace std; struct mono{ bool f=原创 2018-12-29 18:35:23 · 123 阅读 · 0 评论 -
第一周 A - Cleaning Shifts
我真的是太菜了,这道题让我想了好久,最后看别人的解说才明白是区间覆盖问题。 源自poj2376 这道题就是一个套路。。。。 #include <iostream> #include<cstdio> #include <algorithm> using namespace std; const int MAX = 1e6 + 10; struct P { int...原创 2019-04-10 17:23:49 · 161 阅读 · 0 评论 -
B - Andy's First Dictionary (uva 10185)
一道考察细节的题目。 新学到了transform函数的用法,还有就是注意标点符号。 #include <iostream> #include <cstdio> #include <algorithm> #include <set> #include <string> #include <cctype> #include <...原创 2019-04-06 15:05:04 · 148 阅读 · 0 评论 -
hdu 1003 Max Sum
题源 本来以为只是简单的求出最大子序列就好了,结果又仔细一看题目,还需要区间范围,结果我就懵了,上网百度了一下,发现使用dp. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> using namespace std; const int MAX = 1e6 + 1; int num...原创 2019-04-11 16:08:58 · 133 阅读 · 0 评论 -
洛谷p1996
题目链接 简单来模拟一下。 #include<iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int MAX = 1000 + 1; int num[MAX] = {0}; bool book[MAX] = {...原创 2019-03-28 21:49:04 · 246 阅读 · 0 评论 -
poj 3714 Raid
最近点对算法的变形(看别人写的) 两个集合可以放在一起,只要在在跨左右集合寻找最近点的时候判断一下是否都是agent或者都是pow station 就行了。(听说数据很水,我写的也很水)。 题源 #include<iostream> #include <cstdio> #include <algorithm> #include <cmath> #in...原创 2019-04-24 21:01:31 · 175 阅读 · 0 评论