上一页 1 ··· 37 38 39 40 41 42 43 44 45 ··· 47 下一页
摘要: 题目传送门题意:LIS最长递增子序列 O(nlogn)分析:设当前最长递增子序列为len,考虑元素a[i]; 若d[len]#include #include #include using namespace std;const int N = 1e5 + 10;const int INF = 0... 阅读全文
posted @ 2015-04-29 20:27 Running_Time 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 题目传送门题意:一个字符串要变成回文串至少要插入多少个字符分析:LCS,长度 - 原串和反串的最大相同长度就是要插入的个数。解释一下,当和反串相同时,在原串中已经是回文的部分了,那么减去LCS长度后剩下的多少个插入多少个一定就能使原串回文dp数组二维都开5000的话就会超内存,这里就用到了滚动数组,... 阅读全文
posted @ 2015-04-29 20:02 Running_Time 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 题目传送门题意:两个字符串结合起来,公共的字符只输出一次分析:LCS,记录每个字符的路径代码:/* LCS(记录路径)模板题: 用递归打印路径:)*/#include #include #include #include #include using namespace ... 阅读全文
posted @ 2015-04-29 19:58 Running_Time 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 x>=y, 1/x 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 using namespace std;14 1... 阅读全文
posted @ 2015-04-28 16:00 Running_Time 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 暴力:对于每一个数都判断,是否数字全都使用过一遍 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #incl... 阅读全文
posted @ 2015-04-28 15:54 Running_Time 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离; 3 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000即为距离; 4 详细解释:http://www.cnblogs.... 阅读全文
posted @ 2015-04-28 15:31 Running_Time 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:若干小木棍,是由多条相同长度的长木棍分割而成,问最小的原来长木棍的长度; 3 DFS剪枝:剪枝搜索的好题!TLE好几次,终于剪枝完全! 4 剪枝主要在4和5:4 相同长度的木棍不再搜索;5 若新的搜索连第一条都没组合出来,直接break... 阅读全文
posted @ 2015-04-28 15:07 Running_Time 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:手机划屏解锁,一笔连通所有数字,输出所有可能的路径; 3 DFS:全排列 + ok () 判断函数,去除一些不可能连通的点:) 4 */ 5 #include 6 #include 7 #include 8 #include ... 阅读全文
posted @ 2015-04-28 14:37 Running_Time 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 BFS+模拟:dp[i][j][p] 表示走到i,j,方向为p的步数为多少; 3 BFS分4种情况入队,最后在终点4个方向寻找最小值:) 4 */ 5 #include 6 #include 7 #include 8 #... 阅读全文
posted @ 2015-04-27 20:57 Running_Time 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 贪心水题:首先,最少的个数为n最大的一位数字mx,因为需要用1累加得到mx, 3 接下来mx次循环,若是0,输出0;若是1,输出1,s[j]--; 4 注意:之前的0的要忽略 5 */ 6 #include 7 #include ... 阅读全文
posted @ 2015-04-27 20:19 Running_Time 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 水题:一开始看错题意,以为是任意切割,DFS来做;结果只是在中间切出一段来 3 判断是否余下的是 "CODEFORCES" :) 4 */ 5 #include 6 #include 7 #include 8 #include 9 #incl... 阅读全文
posted @ 2015-04-27 19:23 Running_Time 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 设一个b[]来保存每一个a[]的质因数的id,从后往前每一次更新质因数的id, 3 若没有,默认加0,nlogn复杂度; 4 我用暴力竟然水过去了:) 5 */ 6 #include 7 #include 8 #include 9 #i... 阅读全文
posted @ 2015-04-27 17:35 Running_Time 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 贪心水题:找出出现次数>1的次数和res,如果要减去的比res小,那么总的不同的数字tot不会少; 3 否则再在tot里减去多余的即为答案 4 用set容器也可以做,思路一样 5 */ 6 #include 7 #include ... 阅读全文
posted @ 2015-04-27 12:46 Running_Time 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 水题:找排序找中间的价格,若有两个,选价格大的; 3 写的是有点搓:) 4 */ 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include... 阅读全文
posted @ 2015-04-26 15:48 Running_Time 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了; 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #i... 阅读全文
posted @ 2015-04-26 15:43 Running_Time 阅读(261) 评论(0) 推荐(0) 编辑
上一页 1 ··· 37 38 39 40 41 42 43 44 45 ··· 47 下一页