自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 蓝桥杯 七段码(只需dfs+sort)

#include<bits/stdc++.h>using namespace std;vector<vector<int>>v(8);vector<int>temp,t;vector<vector<int>>sum;bool b[8];void dfs(int a){ //cout<<a<<endl; b[a]=1; temp.push_back(a); int i=0; for(

2022-03-26 12:30:42 160

原创 L2-014 列车调度(19行代码AC)

#include<bits/stdc++.h>#include<unordered_map>#define endl '\n'using namespace std;vector<int>v;//不需要二维存储,堆在前面的已经判定好是放哪条隧道的那些没用int main() { int n,a; cin >> n; for (int i = 0; i < n; ++i) { cin >> a; auto it=u

2022-03-19 10:11:45 152

原创 洛谷p4136

#include<iostream>#include<cstring>#include<algorithm>#include<math.h>using namespace std;int main() { int n; while (1) { cin >> n; if (n == 0) break; //由于是最优策略进行走步,不可能出现故意作死让对方赢的情况。 //于是最后的情况一定是走到不能再走,直至格子.

2021-12-08 14:05:10 169

原创 洛谷p1100

自己的三十行模拟:#include<iostream>#include<cstring>#include<algorithm>#include<math.h>using namespace std;int main() { unsigned int n,sum=1,t=0; int a[16], b[16]; cin >> n; for (int i = 0; i < 16; ++i) { a[i] = n &am.

2021-12-08 11:40:39 442

原创 洛谷p4702

数学思路来自:洛谷大佬#include<iostream>#include<cstring>#include<algorithm>#include<math.h>using namespace std;//不能被看似博弈的吓退啊,要用小学附加题想一想int main() { int n,*a,sum=0; cin >> n; a = new int[n+1]; //如在满足ai>ai-1下取石子(i和i-1都为下标.

2021-12-08 10:55:39 708

原创 Educational Codeforces Round 118 (Rated for Div. 2)

#include<iostream>#include <algorithm>#include<cmath>using namespace std;//快速幂long long qpow(long long x, long long base) { long long ans = 1; while (base) { if (base & 1) {//如果最后一位为1 ans *= x; } x = x * x;//不用else.

2021-12-08 09:51:36 91

原创 二分查找和二分搜索树(含插入,查找的递归非递归)

有序顺序表顺序搜索判定树:扩充二叉树(用于分析的判定树):其中第i个内部节点刚好处于第i-1个外部节点和i+1个内部节点之间#include<iostream>#include<queue>using namespace std;//设置为左闭右开//二分查找非递归int BinarySearch(int a[],int low,int high,int x ){ while (low < high) {//左闭右开取等的时候越界 int mid =

2021-12-03 13:12:21 1138

原创 图的遍历(邻接矩阵+邻接表+无向图+有向图+bfs+dfs)

#include<iostream>#include<map>#include<queue>#include<stack>using namespace std;//邻接矩阵template<class T>class MatrixG {public: ~MatrixG() { //delete数组是这样delete 然后如果输出c或者c[x] 目前不会输出东西 推断是 野指针指向地方为空 delete []c;...

2021-11-30 20:01:10 286

原创 优先队列构造哈夫曼编码(文件/map)

**不使用文件进行存储:**#include<iostream>#include<fstream>#include<queue>#include<string>#include<map>using namespace std;template<class T>struct HuffmanNode { double val; T name; HuffmanNode* left,*right;};cla...

2021-11-29 13:26:28 723

原创 Codeforces Round #757 (Div. 2)

#include<iostream>#include<vector>#include<algorithm>using namespace std;int main() { int t, n, l, r, k,a; vector<int>v; cin >> t; while (t--) { cin >> n>>l>>r>>k; for (int i = 0; i &lt..

2021-11-26 23:53:53 487

原创 集合类的建立(基于vector)

class set {public: set(){ MaxSize = elem.size(); } bool contains(int x) { vector<int>::iterator pos;//迭代器 pos = find(elem.begin(), elem.end(), x);//模板函数,直接就可以用?迭代器,迭代器,值 if (pos == elem.end()) { return 0; } return 1; } bool ins

2021-11-17 22:47:15 146

原创 循环队列的类的建立

template <class T>class CirQueue {public: CirQueue(int size) { elements = new T[size]; MaxSize = size; front = 0; tail = 0; } ~CirQueue() { delete[]elements; } bool IsFull() { if ((tail+1) % MaxSize == front) {//tail指向的是末尾元素的下一个

2021-11-16 20:22:55 88

原创 顺序栈—类的构建||双栈共享栈空间

template <class T>class Stack {public: Stack(int size) { elements = new T[size]; MaxSize = size; topp =0; } ~Stack() { delete []elements; } void OverStack() { T* NewArray=NULL; int size = MaxSize; if (topp >= 0.5 * size) {

2021-11-15 18:16:26 259

原创 双向链表/单链表实现栈

双向链表struct node { int val; node* next; node* pre;};class stack {public: stack() { head=new node;//带头节点 head->next = nullptr;//建立的时候要指向空 tail = head; } void push(int x) { p = new node; p->val = x; tail->next = p; p-&gt

2021-11-15 13:40:43 296

原创 双向链表的建立,插入,删除

#include <iostream>using namespace std;struct link{ double num; link* next; link* front;};int main(){ link* p, * head; p = head = new link; //没有头结点的双向链表的建立 for (int i = 0; i < 5; i++) { p->num = i;

2021-11-11 22:26:25 432

原创 有头节点的链表的插入

#include <iostream>using namespace std;struct link{ double num; link* next;};int main(){ link* p, * head; head = new link; //有头结点的链表 头插入 for (int i = 0; i < 5; i++) { p = new link; p->num = i;

2021-11-11 22:21:52 272

原创 循环链表的建立和插入

#include<iostream>using namespace std;struct link{ double num; link* next;};int main(){ //循环链表的建立 link* p, * first; p = first = new link; int n = 5; while (n--) { p->num = n; p->next = new

2021-11-11 20:38:00 353

原创 单链表的建立,插入,删除,查找

#include<iostream>using namespace std;struct List{ double num; List* next;};int main(){ List* head, * p; head = new List; //链表的建立 p = head; int n = 3; while (n--) { p->num = n; p->next

2021-11-11 20:33:48 639

原创 链表插入排序递归非递归

正常的插入排序插入非递归void insertSort(node* head) { node* i, * j;//这个*j不要忘记*啊 错了n次了 for (i = head; i; i = i->next) { for (j = head; j != i; j = j->next) {//当p和q有关的时候,更应该考虑pq为空时候的情况 if (i->val < j->val) { int temp = i->val; i->v

2021-11-11 19:51:41 105

原创 链表选择排序递归非递归

正常的选择排序(伪代码)非递归选择排序void selSort(node * head) {//传入的是地址 node* p, *q,*t=NULL; int mmin = 1 << 30,temp;//位运算,使1左移三十位取一个较大的值(我之前因为这个踩过坑,所以即使有INT_MAX,在数据范围不大的时候,我有时候还是想用这个) for (p = head; p; p = p->next) { for (q = p; q; q = q->next) { if

2021-11-11 17:32:50 266

原创 JAVA快排

JAVA快排 static void quickSort(int begin, int end, char[] a){ int i=begin,j=end;//应该把新的子序列的前后传进去,而不是整个数组的前后。 if(i>=j){ return ;//加一个大于号保险一点 我已经没有脑子去想会不会有什么情况是大于了 } char temp=a[i]; while(i<j){

2021-11-11 16:44:05 547

原创 链表冒泡递归非递归排序

链表反转递归node* reverse(node* head) { if (head || head->next) {//当链表为空的时候逆置 return head; } node * newhead=reverse(head->next);//递归到最后一步后把最后一个节点设为新头 head->next->next = head; head->next = NULL;//确保原先的头逆置为尾之后指向NULL return newhead;}链表反转非

2021-11-11 16:41:28 97

原创 链表递归和非递归反转

非递归反转node* reverse(node* head) { node* a=NULL, b=head, c=NULL;//设一个哨兵节点a while (b) { c = b->next; b->next = a; a=b; b=c;//注意这里赋值不要反了 等同于“将赋值号右边的节点c另起一个名,该名为赋值号左边的节点b” }}递归反转node* reverse(node* head) { if (head || head->next) {//当链

2021-11-11 16:40:27 220

原创 顺序栈实现算术表达式的计算

#include<iostream>#include<string>#include<map>using namespace std;template <class T>class Stack {public: Stack(int size) { elements = new T[size]; MaxSize = size; topp =0; } ~Stack() { delete []elements; } voi.

2021-11-09 21:43:02 1039

转载 2021-11-09

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用Markdown编辑器你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Mar

2021-11-09 21:38:11 46

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除