上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 47 下一页
摘要: 题目传送门 1 /* 2 题意:取长度不小于m的序列使得和最大 3 贪心:先来一个前缀和,只要长度不小于m,从m开始,更新起点k最小值和ans最大值 4 */ 5 #include 6 #include 7 using namespace std; 8 9 const int ... 阅读全文
posted @ 2015-07-16 08:42 Running_Time 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 数学:假设取了第i个,有C(n-1)(i-1)种取法 3 则ans = sum (C(n-1)(i-1)) (1 6 #include 7 #include 8 #include 9 using namespace std;10 11 type... 阅读全文
posted @ 2015-07-16 08:36 Running_Time 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 题意:问区间内x的出现的次数分析:莫队算法:用一个cnt记录x的次数就可以了。还有二分查找的方法代码:#include #include #include #include using namespace std;const int MAXN = 1e5 + 10;const int I... 阅读全文
posted @ 2015-07-16 08:29 Running_Time 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:数据加10组,再删掉第6组数据,问rejudge后最少最多几个作者收到邮件 3 思维题:当错在6时结果是不一定,错在7时是一定改变,因为会变成6 4 思路没错,但用结构题排序一直WA,代码有毒!学习使用set容器。 5 */ 6 #includ... 阅读全文
posted @ 2015-07-15 21:20 Running_Time 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:上司在,员工不在,反之不一定。每一个人有一个权值,问权值和最大多少。 3 树形DP:把上司和员工的关系看成根节点和子节点的关系,两者有状态转移方程: 4 dp[rt][0] += max (dp[son][1], dp[son]... 阅读全文
posted @ 2015-07-14 17:36 Running_Time 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:寻找一个根节点,求min f(u) = ∑ρ(v, u) * p(v)。ρ(v, u)是u到v的距离,p(v)是v点的权值 3 树形DP:先从1出发遍历第一次,sum[u]计算u到所有子节点v的路径权值(之后的点路径有叠加,所以先把路径权值加后*w),... 阅读全文
posted @ 2015-07-14 17:33 Running_Time 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 模拟:找到规律分别输出就可以了,简单但是蛮有意思的 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 const int MAXN... 阅读全文
posted @ 2015-07-14 10:27 Running_Time 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 莫队算法:求出[l, r]上取出两只相同袜子的个数。 3 莫队算法是离线处理一类区间不修改查询类问题的算法。如果你知道了[L,R]的答案,可以在O(1)的时间下得到 4 [L,R-1]和[L,R+1]和[L-1,R]和[L+1,R],... 阅读全文
posted @ 2015-07-14 10:22 Running_Time 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:从i开始,之前出现过的就是之前的值,否则递增,问第p个数字是多少 3 莫队算法:先把a[i+p-1]等效到最前方没有它的a[j],问题转变为求[l, r]上不重复数字有几个,裸莫队:) 4 */ 5 #include 6 #include... 阅读全文
posted @ 2015-07-14 10:19 Running_Time 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:在坐标轴上一群蚂蚁向左或向右爬,问经过ts后,蚂蚁的位置和状态 3 思维题:本题的关键1:蚂蚁相撞看作是对穿过去,那么只要判断谁是谁就可以了 4 关键2:蚂蚁的相对位置不变 关键3:order数组记录顺序 5 */... 阅读全文
posted @ 2015-07-14 10:16 Running_Time 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 题意:n个头,m个士兵,问能否砍掉n个头 3 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 4 */ 5 #include 6 #include 7 #include 8 using namespace std; 9 10 const in... 阅读全文
posted @ 2015-07-14 10:14 Running_Time 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 水! 3 */ 4 #include 5 #include 6 #include 7 using namespace std; 8 9 const int MAXN = 1e2 + 10;10 const int INF = 0x3f3f3f3f;11 ch... 阅读全文
posted @ 2015-07-14 10:13 Running_Time 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 贪心:因为可以任意修改,所以答案是没有出现过的数字的个数 3 */ 4 #include 5 #include 6 #include 7 using namespace std; 8 9 const int MAXN = 5e3 + 10;10 const ... 阅读全文
posted @ 2015-07-14 10:12 Running_Time 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 贪心:全排列函数使用,更新最值 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #i... 阅读全文
posted @ 2015-07-14 10:11 Running_Time 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 题目传送门 1 /* 2 数学题:当有一个数开根号后是无理数,则No 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include... 阅读全文
posted @ 2015-07-14 10:09 Running_Time 阅读(199) 评论(0) 推荐(0) 编辑
上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 47 下一页