#include
#include
#include
using namespace std;
const int m=(int)1E8;
string s1,s2;
int f[2][5001]={0},g[2][5001]={0};
void init();
void work();
int my_max(int,int);
int main()
{
freopen("lcs.in","r"...
分类:
其他好文 时间:
2014-05-26 04:07:17
阅读次数:
305
图像的输入输出
C风格的操作:
const char *pstrImageName = "秽土转生第七版.jpg";
const char *pstrWindowsTitle = "窗口标题";
//从文件中读取图像
IplImage *pImage = cvLoadImage(pstrImageName, CV_LOAD_IMAGE_UNCHANGED);
//创建窗口
cvN...
分类:
其他好文 时间:
2014-05-26 03:47:36
阅读次数:
296
Elegant String
题意:给定一个字符串,由0-k数字组成,要求该串中,子串不包含0-k全排列的方案数
思路:dp[i][j]表示放到i个数字,后面有j个不相同,然后想递推式,大概就是对应每种情况k分别能由那几种状态转移过来,在纸上画画就能构造出矩阵了,由于n很大,所以用快速幂解决
代码:
#include
#include
const long long MOD = ...
分类:
其他好文 时间:
2014-05-25 00:36:34
阅读次数:
211
题目链接:点击打开链接
题意:有两种操作,合并集合,查询第K大集合的元素个数。(总操作次数为2*10^5)
Treap模板(静态数组)
#include
#include
#include
#include
#include
const int maxNode = 500000 + 100;
const int inf = 0x3f3f3f3f;
struct Tr...
分类:
其他好文 时间:
2014-05-24 23:18:09
阅读次数:
522
线程属性
初始化与销毁属性
int pthread_attr_init(pthread_attr_t *attr);
int pthread_attr_destroy(pthread_attr_t *attr);
获取与设置分离属性
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachsta...
分类:
编程语言 时间:
2014-05-24 21:49:29
阅读次数:
361
题目:这个题目里要求最多交易2次。也就是说可以只交易一次,不交易也可以。
分析:将整个交易序列分割成两部分,求出这样的一种分割,使得两部分连续子序列的和相加的结果最大,当然,如果不进行分割,就是求出整个序列的最大连续子序列的和。
那么分割点就可能是任意位置。找出取得最大值的分割点,返回最大值。
int maxProfit(vector &prices) {
const int le...
分类:
其他好文 时间:
2014-05-24 20:54:57
阅读次数:
402
题目:11218 - KTV
题目大意:ktv里有9个人,唱歌的话分三个一组,然后给出n中可能的分组,和每个分组的得分,求最多的得分。
解题思路:这题就是dfs,但是要注意这里的每个人都需要并且只能在一个组里。
代码:
#include
#include
const int N = 100;
int comb[N][3], score[N];
int n, v...
分类:
其他好文 时间:
2014-05-24 20:38:34
阅读次数:
242
第6章 使用库算法
本章中主要教我们如何使用几个库算法来解决与处理字符串和学生成绩相关的问题。
1、分析字符串
使用一个循环来连接两幅字符图案
for(vector::const_iterator it = bottom.begin(); it != bottom.end(); ++it)
ret.push_back(*it);
等价于
ret.insert(ret.end(...
分类:
编程语言 时间:
2014-05-24 20:24:10
阅读次数:
365
尽量以const, enum,inline 替换 #define --》 宁可以编译器替换预处理器...
分类:
编程语言 时间:
2014-05-24 18:29:52
阅读次数:
321