- 博客(7)
- 收藏
- 关注
原创 有关PAT的几道简单模拟的题目
包括A1001、A1002、A1009、A1042、A1046、A1065包括一些思想和解法A1001#include <cstdio>#include <algorithm>using namespace std;const int maxn=100000;int main (){ int a,b; int sum,temp; scanf("%...
2018-12-15 20:17:01 217 1
原创 图的遍历 DFS&BFS A1034head of gang &A1076forwords on weibo
图的遍历有两种方法,深度遍历和广度遍历,可以用邻接表或者邻接矩阵。邻接表用二维数组,邻接矩阵用vector.DFS 深度遍历邻接矩阵:const inf =10000000;//表示两节点之间的距离无限大,说明两节点不联通const int n ;//节点个数int G[maxn][maxn];//表示邻接图bool vis[maxn]={false};//表示节点是否被访问过v...
2018-11-24 10:34:34 156
原创 归并排序,插入排序和堆排序A1089insert or merge和A1098insertion or heap sort
归并排序(merge sort):归并排序是分治思想,类似完全二叉树,先用递归的方法,将其分解(divide)为小数组,递归边界是小数组中数据只为一个,然后用治(conquer)将小数组排序,整合成有序数列。例 :原数组: 14568973分:1: 1456 8973 拆分成完全二叉树序列2: 14 56 89 733: ...
2018-11-14 15:47:41 174
原创 并查集A1107 socialclusters
找朋友用数组来模拟森林#include<cstdio>const int n=100;int father[n];bool isfather[n];int findfather(int x){ int a=x; while(x!=father[x])//查找根节点 { x=father[x]; } while(a!=father[a])//压缩使指向根结点的...
2018-11-09 20:53:34 143
原创 平衡二叉树实现 A1066 root of avl tree
AVL平衡二叉树 实现 查询时间复杂度 O(logn)LL 左旋 root 2 root->lchild=1LR 左旋后右旋 root 2 root->lchild=-1RR 右旋 root=-2 root->rchild=-1RL 右旋后左旋 root=-2 root->rchild=1#include<cstdio>#include<al...
2018-11-09 11:00:39 110
原创 PAT_学习笔记A1039studentlistforcourse和A1047courselistforstudent
A1039studentlistforcourse原题:时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueZhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of ...
2018-10-25 17:29:43 193
原创 PAT考试笔记:A1048_find coins的三种写法
原题目:1048.Find Coins (25)Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of c...
2018-10-22 16:10:14 239
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人