上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 43 下一页
摘要: 对于循环数组的问题,就是找偏移K后位置偏移后位置=起始位置+(相对位置+K)%(长度+1)#include #include #include #include #include #include #include #include using namespace std;#define mem(a... 阅读全文
posted @ 2016-01-26 11:18 qlky 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 还是要注意int和long long的范围,以及double型的问题pow函数经常会报一个double型的错,参考这篇文章http://blog.csdn.net/lawrencesgj/article/details/7773507double pow(double,int)doublesqrt(... 阅读全文
posted @ 2016-01-26 01:36 qlky 阅读(344) 评论(0) 推荐(0) 编辑
摘要: 这道题之前没注意到at least,审题不仔细啊,两个问题解法还是有些许区别的有at least的#include #include #include #include #include #include #include #include using namespace std;#define m... 阅读全文
posted @ 2016-01-26 01:02 qlky 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 这道题需要注意一个点,浮点数的误差问题判断里的0.3*a[i]换成3*a[i]/10就过了这个后面还要专门研究一下#include #include #include #include #include #include #include #include using namespace std;#... 阅读全文
posted @ 2016-01-25 23:13 qlky 阅读(235) 评论(0) 推荐(0) 编辑
摘要: http://blog.csdn.net/a_eagle/article/details/7213236公共序列可以用一个二维数组dp[i][j]保存每个点时的最大数字,本质就是一个双向比较。dp[i][j] = dp[i-1][j-1]+1;(a[i]==b[j])dp[i][j] = max(d... 阅读全文
posted @ 2016-01-24 17:38 qlky 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 这题状态方程很容易得到:DP[i][j] = max(DP[i-1][j],DP[i+1][j],DP[i][j-1],DP[i][j+1]) + 1难点在于边界条件和剪枝,因为这方程的条件是点在map里,且只有递增关系才会变化,如果用循环的话要判断递增,所以用递归比较方便#include #inc... 阅读全文
posted @ 2016-01-24 16:55 qlky 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 求最长总和序列,状态转移方程:dp[i] = max(dp[i-1]+a[i].a[i])因为可能有负数,所以要判断dp是否大于0,如果小于0则序列中断,从中断点开始起始点可以用数组s保存,有中断点就保存,没有的话s[i]=s[i-1]另外还有输出最后换行的问题,有时中间要换行但最后不需要换行,如果... 阅读全文
posted @ 2016-01-24 15:17 qlky 阅读(325) 评论(0) 推荐(0) 编辑
摘要: 因为是全连接图,所以也可以用最小生成树这道题给边加了一个限制条件,(10#include #include #include using namespace std;#define sf scanf#define pf printf#define debug printf("!\n")#define... 阅读全文
posted @ 2016-01-24 10:52 qlky 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 这题要把给的字符串变成边的权值#include #include #include #include using namespace std;#define sf scanf#define pf printf#define debug printf("!\n")#define blank print... 阅读全文
posted @ 2016-01-24 10:45 qlky 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 用kruskal算法,利用w[i]给r[i]间接排序,从而r[i]可以按照边大小保存序号,同时要判断是否在一个集合里面#include #include #include using namespace std;#define sf scanf#define pf printf#define deb... 阅读全文
posted @ 2016-01-24 10:42 qlky 阅读(195) 评论(0) 推荐(0) 编辑
上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 43 下一页