随笔分类 -  算法竞赛入门

算法竞赛入门经典(第2版) -刘汝佳
摘要:没看解答敲了一遍,发现自己题目的理解能力有点差 虽然能实现四叉树的合并但并不能算出像素:-( 然后看答案后又敲了遍 阅读全文
posted @ 2017-08-04 22:22 lan126 阅读(127) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int const maxn=10000; 8 int sum[maxn]; 9 10 11 void built(int p) 12 { 13 int v; 14 cin>>v; 15 16 if(v==-1)... 阅读全文
posted @ 2017-08-02 17:26 lan126 阅读(104) 评论(0) 推荐(0)
摘要:本来准备模仿前几题建树来做,但是发现判断部分还是要写出答案那样. 阅读全文
posted @ 2017-08-02 07:19 lan126 阅读(143) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 4 using namespace std; 5 6 const int maxn=100000; 7 int n; 8 int postorder[maxn],inorder[maxn]; 9 int lh[maxn],rh[maxn]; 10 11 12 bool read_list(int* a) 13 { 14... 阅读全文
posted @ 2017-07-30 17:37 lan126 阅读(141) 评论(0) 推荐(0)
摘要:1.指针实现 2.数组实现 书上的接口写的太棒了,换了种实现方式,代码基本上没改,比我自己写的接口不知道高到哪里去了. 阅读全文
posted @ 2017-07-28 21:46 lan126 阅读(271) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 4 using namespace std; 5 6 int btr[1<<20]; 7 8 9 int main() 10 { 11 int D,I; 12 13 while(scanf("%d%d",&D,&I)==2) 14 { 15 m... 阅读全文
posted @ 2017-07-27 21:33 lan126 阅读(143) 评论(0) 推荐(0)
摘要:6-4 自己先敲了一遍虽然可以完成书上的功能但是漏洞百出 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 5 using namespace std; 6 7 const int maxn=100000+100; 8 阅读全文
posted @ 2017-07-25 22:22 lan126 阅读(151) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 vector vt; 8 stack st; 9 10 int main() 11 { 12 vt.clear(); 13 14 int n; 15 cin>>n; 16 17 for(int i... 阅读全文
posted @ 2017-07-25 15:29 lan126 阅读(128) 评论(0) 推荐(0)
摘要:5-8 5-9 Databa 阅读全文
posted @ 2017-07-24 14:47 lan126 阅读(111) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 struct BigInteger 8 { 9 static const int BASE=100000000; 10 static const int WIDTH=8; 11 12 vector... 阅读全文
posted @ 2017-07-22 21:06 lan126 阅读(130) 评论(0) 推荐(0)
摘要:稍微测试了一下cin的用法和字节流的用法 5-3 5-4 5-5 5-6 5-7 阅读全文
posted @ 2017-07-19 11:49 lan126 阅读(173) 评论(0) 推荐(0)
摘要:自己敲了一遍4-5 阅读全文
posted @ 2017-07-17 12:01 lan126 阅读(138) 评论(0) 推荐(0)
摘要:例题4-3 这里最要注意的是13行的移动一位的操作,p = (p+d-1+n) % n+1 是为了在1-n 之间循环 如果是在0 -n 之间循环应该写为 p=(p+d+n)%n 例题 4-4 阅读全文
posted @ 2017-07-16 10:33 lan126 阅读(156) 评论(0) 推荐(0)
摘要:3-5 阅读全文
posted @ 2017-07-14 11:47 lan126 阅读(137) 评论(0) 推荐(0)
摘要:3-2 Molar_Mass 刚开始纠结于不用数组,结果各种程序漏洞,改成用数组后不仅逻辑更加清晰也更好写了 3-3 Digit Counting 用sprintf可以写出很简介的代码 这里有篇关于sprintf用法的文章,感觉很有用 阅读全文
posted @ 2017-07-13 17:07 lan126 阅读(148) 评论(0) 推荐(0)
摘要:1 #include 2 3 int main() 4 { 5 int c,q=1; 6 7 FILE *fin; 8 fin=fopen("TeX.out","r"); 9 10 while((c=fgetc(fin))!=EOF) 11 { 12 if(c=='"') 13 { 14 ... 阅读全文
posted @ 2017-07-12 15:51 lan126 阅读(223) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 4 #define maxn 20 5 6 int a[maxn][maxn]; 7 8 int main() 9 { 10 memset(a, 0, sizeof(a)); 11 12 int x = 0; 13 int y = maxn - 1; 14 int tot = a[x][y]... 阅读全文
posted @ 2017-07-11 17:09 lan126 阅读(195) 评论(0) 推荐(0)
摘要:习题2-1 习题2-2 2-3 2-4所谓陷阱就是溢出注意注释部分的内容 2-5 阅读全文
posted @ 2017-07-10 17:09 lan126 阅读(145) 评论(0) 推荐(0)