摘要: 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)