
LightOJ
文章平均质量分 87
synapse7
这个作者很懒,什么都没留下…
展开
-
LightOJ 1136 Division by 3 (想法题)
http://www.lightoj.com/volume_showproblem.php?problem=1136开始打算解二次同余的,算了一会发现有很多解。。-->转而分析序列结构。分析发现:连续三个整数并排在一起组成的数的数字和必然能被3整除。(x+x+1+x+2=3x+3=3(x+1))从而有:1.题目中的第3k个数,必然能被三整除。2. 题目中的第原创 2013-11-29 19:28:04 · 1792 阅读 · 1 评论 -
LightOJ 1062 Crossed Ladders (二分)
http://lightoj.com/volume_showproblem.php?problem=1062/*0.000s,1700KB*/#includeusing namespace std;double EPS = 1e-8;int main(){ double a, b, c, j, c1, h, k, x; int T, cas = 0; scanf("原创 2014-03-26 18:57:16 · 1518 阅读 · 0 评论 -
LightOJ 1203 Guarding Bananas (凸包最小顶角)
http://lightoj.com/volume_showproblem.php?problem=1203/*0.164s,6512KB*/#includeusing namespace std;#define sqr(x) ((x)*(x))const double INF = 1e100;const double pi = acos(-1.0);const doub原创 2014-03-26 17:52:26 · 1487 阅读 · 0 评论 -
UVa 109 SCUD Busters (凸包面积&判断点是否在凸包内部)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=45套模板即可。一道类似的题:LightOJ 1190 Sleepwalking完整代码:/*0.018s*/#includeusing namespace s原创 2014-02-14 22:25:23 · 1164 阅读 · 0 评论 -
POJ 2559 / HDU 1506 / LightOJ 1083 Largest Rectangle in a Histogram (单调栈)
Largest Rectangle in a Histogramhttp://poj.org/problem?id=2559Time Limit: 1000MSMemory Limit: 65536KDescriptionA histogram is a polygon composed of a sequence of rectangles ali原创 2013-09-19 18:07:02 · 1859 阅读 · 0 评论 -
LightOJ 1085 All Possible Increasing Subsequences (DP&离散化&树状数组)
http://lightoj.com/volume_showproblem.php?problem=1085先说个很快的方法——二维思考,从右下往左上离散化:/*0.364s,2860KB*/#includeusing namespace std;const int mx = 100005;const int mod = 1000000007;int tree[m原创 2014-03-25 21:28:21 · 1662 阅读 · 0 评论 -
LightOJ 1009 Back to Underworld (种类并查集)
http://lightoj.com/volume_showproblem.php?problem=1009种类并查集实现(当然用二分图染色也可以)/*0.204s,2820KB*/#includeusing namespace std;const int mx = 20000;int fa[mx * 2 + 5], rk[mx * 2 + 5], x[100005原创 2014-03-24 16:35:47 · 1730 阅读 · 0 评论 -
LightOJ 1080 Binary Simulation (线段树&成段更新)
http://lightoj.com/volume_showproblem.php?problem=1080模板。/*0.484s,4312KB*/#include #include #include using namespace std;#define lson l , m , rt << 1#define rson m + 1 , r , rt << 1 | 1原创 2014-03-24 08:18:36 · 1446 阅读 · 0 评论 -
LightOJ 1258 Making Huge Palindromes (回文&KMP)
http://lightoj.com/volume_showproblem.php?problem=1258首先原串+翻转过来的串必然是一个回文串,但是二者在中间可以“融合”,而KMP算法恰好可以求出最大融合长度。所以看翻转过来的串能匹配多少原串即可,答案就是len+(len-匹配个数)。完整代码:/*0.140s,7548KB*/#includeusin原创 2014-03-27 13:40:28 · 1834 阅读 · 0 评论 -
LightOJ 1255 Substring Frequency (KMP模板)
http://lightoj.com/volume_showproblem.php?problem=1255/*0.068s,7548KB*/#includeusing namespace std;const int mx = 1000005;char t[mx], p[mx];int f[mx];void getfail(){ f[0] = f[1] = 0原创 2014-03-26 23:27:28 · 1447 阅读 · 0 评论