2020年2月5日
摘要: 二分的基本用途是在单调序列或单调函数中做查找操作 三分解决单调函数极值及相关问题,例如凸性函数,二次函数就是,利用函数的单峰性,如果函数不严格单调,那就不能适用 一本通题目 一、取余运算:输入b<span id="MathJax-Span-2" class="mrow"><span 阅读全文
posted @ 2020-02-05 21:36 shirlybabyyy 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 一本通 递归太常用了,其实很多时候在复杂的代码里面理解起来还比较麻烦 在排序里面的应用:快速排序和归并排序 经典例题:汉诺塔 #include<bits/stdc++.h> using namespace std; int n,k; void mov(int n,char a,char c,char 阅读全文
posted @ 2020-02-05 21:26 shirlybabyyy 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 一本通的题 一、昆虫繁殖 #include<iostream> using namespace std; //昆虫繁殖 int main(){ long long a[101]={0},b[101]={0},i,j,x,y,z; cin>>x>>y>>z; for(i=1;i<=x;i++) {a[ 阅读全文
posted @ 2020-02-05 21:01 shirlybabyyy 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 堆的操作,用数组实现 包括插入操作--自底向上调整、删除操作--把最后一位赋值给堆顶,然后从堆顶向下调整 #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<stack> #include 阅读全文
posted @ 2020-02-05 20:04 shirlybabyyy 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 队列:一边入队,一边出队 queue、双端队列deque、优先队列priority_queue 优先队列:因为优先队列本质是堆,注意比较函数的写法 struct node{ string name; int pri; friend bool operator < (node f1,node f2){ 阅读全文
posted @ 2020-02-05 18:42 shirlybabyyy 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 主要包括一些中缀、后缀表达式值的计算、表达式是否合法的判断 后缀表达式的讲解: https://baike.sogou.com/v53851686.htm?fromTitle=%E5%90%8E%E7%BC%80%E8%A1%A8%E8%BE%BE%E5%BC%8F&ch=frombaikevr 人 阅读全文
posted @ 2020-02-05 17:38 shirlybabyyy 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 3、数论 3.1 最小公倍数 GCD int gcd(int a,int b){ //辗转相除 if(b==0) return a; else return gcd(b,a%b); } int gcd(int a,int b){ return !b ? a:gcd(b,a%b); } 最大公约数 L 阅读全文
posted @ 2020-02-05 16:13 shirlybabyyy 阅读(153) 评论(0) 推荐(0) 编辑