摘要: 算法 类型 Structure function 备注 不变序列算法O(n) 顺序容器/关联容器均适用 iterator min_element(iterator first, iterator last[,Pred op]) iterator max_element(iterator first, 阅读全文
posted @ 2019-12-13 20:58 飞翔的菜鸟123 阅读(279) 评论(0) 推荐(0) 编辑
摘要: `1.树的搜索 ` order traverse 思路1:bfs(要建树的数据结构) 思路2:dfs(要Node结构体) cpp const int maxn = 1010; vector g[maxn];//已知结点关系 void dfs(int x, int dp) {//depth运用 pat 阅读全文
posted @ 2019-12-13 20:53 飞翔的菜鸟123 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 1.数连通分量(并查集) PAT1013 Battle Over Cities 法1:每次dfs前判断visit[i]==0; cpp while(K ){ int v;int num=0; scanf("%d",&v); iota(father,father+N+1,0);//初始化并查集 for 阅读全文
posted @ 2019-12-13 20:44 飞翔的菜鸟123 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1.数学问题 (1)素数 算术基本定理:若$a\in Z$,$a\gt 1$,则有$a=p_1p_2\cdots p_n$,其中$p_i$为素数 证明:假定定理对所有小于a的正整数均成立 若a为素数,则结论显然成立 若a为合数,$a=bc$,其中$1\lt b,c\lt a$由归纳假设$b=p_1p 阅读全文
posted @ 2019-12-13 20:43 飞翔的菜鸟123 阅读(275) 评论(0) 推荐(0) 编辑
摘要: PAT暂时没有题目练习拓扑排序,以下是Leetcode题目 There are a total of n courses you have to take, labeled from 0 to n 1.Some courses may have prerequisites, for example 阅读全文
posted @ 2019-12-13 17:28 飞翔的菜鸟123 阅读(239) 评论(1) 推荐(0) 编辑