01 2016 档案

摘要:例题 例题5-1 大理石在哪儿(Where is the Marble?,Uva 10474) 主要是熟悉一下sort和lower_bound的用法 关于lower_bound: http://blog.csdn.net/niushuai666/article/details/6734403 此外还 阅读全文
posted @ 2016-01-31 22:02 qlky 阅读(513) 评论(0) 推荐(0)
摘要:memcmp(const void *buf1, const void *buf2, unsigned int count)可以比较两个串相等 http://baike.baidu.com/link?url=moP6BHDBs7PfCbVKaICYTP9biwBKdYjBfy2Raz45kwLx1S 阅读全文
posted @ 2016-01-31 17:24 qlky 阅读(285) 评论(0) 推荐(0)
摘要:我的思路是A右与B左对齐,然后一路滑过去,寻找其中的最小值。然而WA。。 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #i 阅读全文
posted @ 2016-01-31 16:12 qlky 阅读(314) 评论(0) 推荐(0)
摘要:首先可以用fgets读取一行,用辅助字符数组保存字母和在原数组的序号 http://blog.chinaunix.net/uid-22566367-id-381994.html http://blog.chinaunix.net/uid-21757287-id-327365.html 接下来有几种方 阅读全文
posted @ 2016-01-31 00:54 qlky 阅读(217) 评论(0) 推荐(0)
摘要:最小周期可以用%枚举 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #includ 阅读全文
posted @ 2016-01-30 23:54 qlky 阅读(238) 评论(0) 推荐(0)
摘要:对于序列的最小值,可以定义一个比较的方法,然后用一般找最小值的方法遍历一遍即可 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> 阅读全文
posted @ 2016-01-30 22:55 qlky 阅读(251) 评论(0) 推荐(0)
摘要:对于这种需要一遍遍枚举求解的,打表可以提高很多效率 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <alg 阅读全文
posted @ 2016-01-30 21:44 qlky 阅读(295) 评论(0) 推荐(0)
摘要:可以先设一个常量镜像串,直接返回比较 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> 阅读全文
posted @ 2016-01-30 14:24 qlky 阅读(805) 评论(0) 推荐(0)
摘要:sprintf 一个可以将输入打印到字符串的函数,用法与printf差不多 可以参考这篇文章: http://blog.csdn.net/masibuaa/article/details/5634886 //把整数123 打印成一个字符串保存在s 中。 sprintf(s, "%d", 123); 阅读全文
posted @ 2016-01-28 00:43 qlky 阅读(181) 评论(0) 推荐(0)
摘要:可以将一个数组里的内容复制到另一个数组 memcpy(b,a,sizeof(int)*k)复制a中k个,memcpy(b,a,sizeof(a))覆盖a全部 如果b该位置原先有值会被覆盖,超范围会截取 复制不同数据类型的数组得不到预期的结果 阅读全文
posted @ 2016-01-27 22:50 qlky 阅读(219) 评论(0) 推荐(0)
摘要:#define LOCAL #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #inc 阅读全文
posted @ 2016-01-27 22:32 qlky 阅读(161) 评论(0) 推荐(0)
摘要:1.sqrt(-10)用%d输出是0.%lf输出则是-1.#IND00 http://blog.sina.com.cn/s/blog_3e6817300100a74d.html 2.除常数0会报错,除变量0程序会崩溃 3.printf中输出%可以用%%,输出/用// 4.int型最大值为214748 阅读全文
posted @ 2016-01-27 22:23 qlky 阅读(137) 评论(0) 推荐(0)
摘要:输出所有aabb型的完全平方数这个问题主要是提供一个判断完全平方的思路,就是用floor函数#include #include #include #include #include #include #include #include using namespace std;#define mem(... 阅读全文
posted @ 2016-01-26 23:23 qlky 阅读(215) 评论(0) 推荐(0)
摘要:http://blog.csdn.net/libin56842/article/details/12947849http://blog.csdn.net/yuzhiyuxia/article/details/38728997http://www.cnblogs.com/shuaiwhu/archiv... 阅读全文
posted @ 2016-01-26 14:12 qlky 阅读(137) 评论(0) 推荐(0)
摘要:对于循环数组的问题,就是找偏移K后位置偏移后位置=起始位置+(相对位置+K)%(长度+1)#include #include #include #include #include #include #include #include using namespace std;#define mem(a... 阅读全文
posted @ 2016-01-26 11:18 qlky 阅读(283) 评论(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 阅读(356) 评论(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 阅读(218) 评论(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 阅读(248) 评论(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 阅读(402) 评论(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 阅读(291) 评论(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 阅读(338) 评论(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 阅读(270) 评论(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 阅读(238) 评论(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 阅读(201) 评论(0) 推荐(0)
摘要:这道题多了一个检查是否包含所有元素可以设一个cnt表示集合里的数量,再与外面比较#include #include #include using namespace std;#define sf scanf#define pf printf#define debug printf("!\n")#de... 阅读全文
posted @ 2016-01-24 10:39 qlky 阅读(186) 评论(0) 推荐(0)
摘要:并查集主要是两个过程,一个是并,一个是查原理是用一个数组p[i]保存每个i的根节点,如果根节点一样则在同一个集合里,所以只有根节点p[i]=i;查:int find(int x){return p[x]==x?x:p[x]=find(p[x]);}并:void Union(int x,int y){... 阅读全文
posted @ 2016-01-24 10:36 qlky 阅读(245) 评论(0) 推荐(0)
摘要:while(t--)最后结果t=-1#include #include #include #include #include #include #include #include using namespace std;#define MEM(a,b) memset(a,b,sizeof(a))#d... 阅读全文
posted @ 2016-01-24 01:07 qlky 阅读(310) 评论(0) 推荐(0)
摘要:这道题提醒我两点:1.break时一定要检查清楚2.字符串直接赋值一定要注意结束符,最好能用strcpy以上是debug的惨痛教训#include #include #include #include #include #include #include #include using namespa... 阅读全文
posted @ 2016-01-24 00:50 qlky 阅读(314) 评论(0) 推荐(0)
摘要:这道题有个需要注意的地方,就是范围大小2^16 = 65535,2^32 = 65535(10^4),2^16 =4294967295(10^9),2^64=9223372036854775807(10^18)这道题范围到10^9,3次方就超过了long long,所以可以用除法作为判定条件#inc... 阅读全文
posted @ 2016-01-23 23:24 qlky 阅读(276) 评论(0) 推荐(0)