上一页 1 2 3 4 5 6 7 8 ··· 42 下一页
哎,CF终于变色了A题:我写了个二分,囧。。。B题:模拟题,水C题:想了半天,水王(一学长)告诉我是DP,果断敲了dp[i][j]表示i字符走到j字符最大的权值View Code int dp[30][30];int max(int a,int b){ return a>b?a:b;}int main(){ int n,i,j,k; char s[15]; while(scanf("%d",&n)!=EOF) { memset(dp,0,sizeof(dp)); for(k=1;k<=n;k++) { ... Read More
posted @ 2012-05-28 03:14 Because Of You Views(426) Comments(0) Diggs(0) Edit
A题:水题B题:水题C题:用栈来做D题:数学题,需要仔细地分类讨论E题:给你n个数围成一个环,若两个数之间没有比他们更大的数,则称两个数是一对合法的数问n个数中共有几对数合法类似于动态规划,一个相似的题目先破环,变成一条线,把最大的元素放到两个端点(增加了一个元素)用两个数组l[],r[] l[]记录某元素往左边第一个严格大于它的数的位置,r[]记录某元素的右边第一个严格大于它的数的位置。c[i]记录i位置的数与l[i]或r[i]之间等于num[i]的数的个数具体见http://codeforces.com/blog/entry/213代码写的有点搓View Code #include< Read More
posted @ 2012-05-28 02:55 Because Of You Views(235) Comments(0) Diggs(0) Edit
有n个数,刚开始都为0add i , j 给i,j区间内的数都加1Q i j 询问i、j间能被三整除的数的个数线段树记录三个域对三取余为0的数的个数。。。。。1.。。。。。。。。。。2.。。。。。可以保存在一个数组里面考虑到每次给一个区间加1的时候,区间内对3取余为1的数的个数变成了对三取余为2,2的变成了0,0的变成了1所以每次更新到区间或者把信息(懒惰标记)往下传的时候只需要把相应的域做一下调整即可View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace s Read More
posted @ 2012-05-27 23:20 Because Of You Views(950) Comments(0) Diggs(0) Edit
http://202.120.106.94/onlinejudge/problemshow.php?pro_id=542背包练习题简单的概括下题意有一个函数 f(x)现有n个未知数x1 x2 x3....xnsigma(xi)= S求f(x1)+f(x2)+f(x3)+..+f(xn)的最大值n s 的最大值都是100这不就是泛化背包吗?每个物品的价值随着你分配给它的体积的变化而变化,最后求体积为S的背包能装进的物品的最大价值注意相同答案时 要输出前面的体积尽可能大的方案,我很懒,可以参考 这里View Code #include<cstdio>#include<cstrin Read More
posted @ 2012-05-27 14:36 Because Of You Views(307) Comments(0) Diggs(0) Edit
ABC水题D:n个二元组,求最长的一个序列组seq,序列的每一个元素的两个值都分别大于前一个元素记忆化搜索或者筛选后DP都可以两种方法View Code #include<cstdio>#include<cstring>#include<set>#include<string>#include<iostream>#include<map>#include<vector>#include<algorithm>using namespace std;#define DEBUG printf(" Read More
posted @ 2012-05-22 17:56 Because Of You Views(237) Comments(0) Diggs(0) Edit
A:裸的广搜题,需要输出路径B:贪心抓住题目的特殊性,每个物品只有1 2 两种体积先按性价比排序,贪心的优先选择性价比高的,某次选了之后体积超了,就剪掉这样子遍历一遍之后还不是答案因为可能会有1体积的空位,而可能通过去掉已选集合中某个1体积的物品,再用一个2体积的物品替代达到更优解所以这里要判断一下View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn = 100010;struct node { int type; in Read More
posted @ 2012-05-21 17:13 Because Of You Views(272) Comments(0) Diggs(0) Edit
http://www.lightoj.com/volume_showproblem.php?problem=14271427 - Substring Frequency (II)PDF (English)StatisticsForumTime Limit:5 second(s)Memory Limit:128 MBA string is a finite sequence of symbols that are chosen from an alphabet. In this problem you are given a stringTandnqueries each with a stri Read More
posted @ 2012-05-20 13:48 Because Of You Views(906) Comments(0) Diggs(0) Edit
给你一个主串再给你很多模式串对于每个串分别判断它在主串中出现了几次每个模式串还有一个flag标记 0:匹配的时候可以重叠 1:匹配的时候不能重叠在匹配的时候判断当期节点上一次匹配的时候在主串中的位置与当前位置之差是否大于模式串的长度即可View Code #include<cstdio>#include<cstring>const int MM = 500005,NC = 26;int N;char str[100010];char s[100010];int x[100010];int flag[100010];struct trie{ int ch[NC],fail Read More
posted @ 2012-05-19 23:57 Because Of You Views(331) Comments(0) Diggs(0) Edit
A题:模拟题,仔细点就好B题:DP给你一个数字矩阵,要求从左上角走到右下角的一条路径,这条路径上的数乘起来后末尾的0的个数最少末尾的0是由2、5产生的,于是联想一下是不是走2最少的一条路或者5最少的一条路就ok了呢?嗯,就是ok的.*_*假设从左上角走到右下角走过的数含因子2的最小的个数是x,5的最小的个数是y,则答案是min(x,y),即最优解x、y的个数中有一项是最少的证明:用反证法,假设最优解经过的数含a个2,b个5,a>x,b>y,易得答案肯定大于min(x,y),所以最优解的x、y肯定有一项是最小的View Code #include<cstdio>#incl Read More
posted @ 2012-05-19 16:00 Because Of You Views(291) Comments(0) Diggs(0) Edit
A 大水题B 模拟题,要很小心,注意细节处理C 给你在一个正多边形上的三个点,判断这个多边形的最小面积。由于这个多边形最多只有100条边,可以直接枚举多边形的边数计算是否满足判断是否满足:三个点组成的三角形的每个角是圆周角的整数倍判断整数的时候精度不宜太大View Code #include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>using namespace std;const double eps = 1e-8;const double pi = acos(-1.0); Read More
posted @ 2012-05-17 21:34 Because Of You Views(260) Comments(0) Diggs(0) Edit
上一页 1 2 3 4 5 6 7 8 ··· 42 下一页