上一页 1 ··· 6 7 8 9 10 11 12 下一页
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=36今天突然想到那天文哥给我看的最长公共子序列的问题....然后自己找了这道题来看看..那天文哥叫我看的时候, 自己就这么一下扫过去. 没什么概念.今天自己从头按照它的分析方法来分析了下.f[i][j] 表示 s1 的 i 个字符和 s2 的 j 个字符内最长的公共子序列if(s1[i] == s2[j]) f[i][j] = f[i-1][j-1] + 1;else f[i][j] = max(f[i-1][j], f[i][j-1]); 当不相同的时候,则考虑在 s1 的 i 个字符和 s.. 阅读全文
posted @ 2012-09-04 16:03 YORU 阅读(370) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1058话说这题是动态规划的吧. 刚开始就想到的是直接暴力, 用一个有序数列.数列的最开头的数字是最小的,然后将它乘以2,3,5,7后得到的数字放回数列中,同时将第一个数字出列....然后只要出了5842个数字就刚好了.set 容器刚好满足 1.去重, 2.排序 View Code 1 #include <stdio.h> 2 #include <iostream> 3 #include <set> 4 using namespace std; 5 const int max 阅读全文
posted @ 2012-09-03 21:07 YORU 阅读(187) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=44水题一道. 很早的时候就知道怎么做了,但是以前都是只知道是怎么做的. 但是自己没有去分析过...第 i 位的时候,如果求的值要最大则是ans[i]=max(ans[i-1]+a[i], a[i]);View Code 1 #include <stdio.h> 2 #define maxn 1000005 3 int ans[maxn], a[maxn]; 4 int max(int a, int b) 5 { 6 return a > b ? a : b; 7 } 8 int 阅读全文
posted @ 2012-09-03 20:02 YORU 阅读(240) 评论(0) 推荐(0)
摘要: http://blog.csdn.net/niushuai666/article/details/7400587看过神牛的RMQ算法之后自己算是默写了遍.....交上去的时候,华丽丽的超时了。因为我用的是 cin cout才想到当输入和输出的次数多时,那么这两个是很耗时间的。View Code 1 2 #include <iostream> 3 #include <stdio.h> 4 #include <cmath> 5 using namespace std; 6 const int maxn= 100010; 7 int maxsum[maxn][20 阅读全文
posted @ 2012-09-03 17:02 YORU 阅读(217) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3183思路:如果没有别的可能的话,只能是最后的N位。但是前面的可能有比N位中的首位更小的数字m,然后找到这个更小的。再从m开始到最后N-1位找N-1位数字的首数字。View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 1005 4 char s[maxn]; 5 int ans[maxn]; 6 int main() 7 { 8 int i, l, n, len, d, end, mark; 9 char 阅读全文
posted @ 2012-09-03 11:40 YORU 阅读(237) 评论(0) 推荐(0)
摘要: http://blog.csdn.net/niushuai666/article/details/6624672通过学习这位神牛的文章初步认识 RMQ....View Code 1 #include <iostream> 2 #include <cmath> 3 #define maxn 10005 4 using namespace std; 5 int maxsum[maxn][20], minsum[maxn][20]; 6 7 void RMQ(int num) //预处理->O(nlogn) 8 { 9 int i, j;10 for(j = 1; j 阅读全文
posted @ 2012-09-03 10:19 YORU 阅读(655) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=104看了下别人的解题报告, 才知道原来还是相当于一维的数组的最大子序列的问题....只是将二维的数组转换为一维的数组继续求最大子序列View Code 1 #include <stdio.h> 2 #define maxn 101 3 int ans[maxn], temp[maxn][maxn]; 4 int row(int n, int ans[]) 5 { 6 int i, b=0, sum=-1000000; 7 for(i=0; i<n; i++) 8 { 9... 阅读全文
posted @ 2012-09-02 15:29 YORU 阅读(353) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=311View Code 1 #include <stdio.h> 2 #define maxn 50005 3 #define INF -1 4 int ans[maxn],v[maxn],w[maxn]; 5 int main() 6 { 7 int t, n, m, i, j; 8 scanf("%d",&t); 9 while(t--)10 {11 scanf("%d%d",&n,&m);12 for(i=0; i 阅读全文
posted @ 2012-09-02 11:17 YORU 阅读(138) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1176数塔问题的变形.....(算不上变形吧..View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 100005 4 int ans[maxn][13], dp[maxn][13]; 5 int max(int a, int b, int c) 6 { 7 return (a > b ? a : b) > c ? (a > b ? a : b) : c; 8 } 9 int main( 阅读全文
posted @ 2012-09-01 16:21 YORU 阅读(144) 评论(0) 推荐(0)
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=666本来是找背包问题做的. 搜到这题, 结果完全没有背包的思路, 看了别人的题解. 也不觉得是背包.....⊙﹏⊙b汗View Code 1 #include <iostream> 2 #define maxn 305 3 using namespace std; 4 int ans[maxn], v[20]; 5 int main() 6 { 7 int i, j, m, count; 8 for(i = 1; i <= 17; i++) 9 v[... 阅读全文
posted @ 2012-08-31 16:34 YORU 阅读(141) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 下一页