随笔分类 - 模板(Template)
摘要:1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 5 using namespace std; 6 7 int z[100],n; 8 9 //快速排序的思想是递归10 //以当前区间中的某个元素为基准 将比它小的放到前面 比它的放到后面 这样之后可以分而治之 因为以它为一个值的分界已经将比它小的放到了前半部分 比它大的放到了后面部分 这样便可以又对前半部分和后半部分执行同样的递归操作 最终完成排序11 12 void qsort(int a,int b)//当前要处理a-b这个区间13
阅读全文
摘要:1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 5 using namespace std; 6 7 char s1[100],s2[100]; 8 9 int x[100],y[100],z[100];10 11 int max(int a,int b)12 {13 if (a>b) return a;14 else return b;15 }16 17 int main()18 {19 scanf("%s%s",s1+1,s2+1);//读入两个字符串 +
阅读全文
摘要:题目背景为八中2002。link cut tree代码量小,比树链剖分好写多了,而且复杂度也比树链剖分低,但由于splay的存在,常数比较大,但不失为一种十分优秀的数据结构。View Code 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 5 using namespace std; 6 7 const int maxn=200010; 8 9 int n,m; 10 11 struct node 12 { 13 int l,r,f,size; 14 bool rt; 15 ...
阅读全文
摘要:题目背景为TSP。View Code 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 #include<ctime> 7 8 using namespace std; 9 10 const int maxn=100; 11 const double max_t=10000.0; 12 const double ratio=0.98; 13 const double eps
阅读全文


浙公网安备 33010602011771号