
pat-复习
二刷
江船夜雨听笛
我无法原谅 什么都不做 却抱有期待的自己 行动起来 必须行动起来
展开
-
pat 2020秋 第二题
400 300 200 500 400 300 200 200 200 3007-2How Many Ways to Buy a Piece of Land(25分)The land is for sale in CyberCity, and is divided into several pieces. Here it is assumed that each piece of land has exactly two neighboring pieces, except the fir.原创 2021-03-06 11:32:59 · 371 阅读 · 0 评论 -
pat 复习 2020秋季 逻辑题交错比较
7-1Panda and PP Milk(20分)PP milk (盆盆奶)is Pandas' favorite. They would line up to enjoy it as show in the picture. On the other hand, they could drink in peace only if they believe that the amount of PP milk is fairly distributed, that is, fatter pa转载 2021-03-06 10:54:36 · 312 阅读 · 0 评论 -
pat 秋 Professional Ability Test
7-4Professional Ability Test(30分)Professional Ability Test (PAT) consists of several series of subject tests. Each test is divided into several levels. Level A is a prerequisite (前置要求) of Level B if one must pass Level A with a score no less than SSS原创 2021-03-05 22:59:19 · 1114 阅读 · 0 评论 -
DFS
如何写出dfs1.判断需要用dfs的情况明显树、图时不明显 _些实际的凑东西 模拟的时候 比较明显的情况有回溯时 在前个不变的情况下下一个不符合则倒回到上一个结点再选其他的2.当确定需要dfS时考虑1.阶段是什么各个阶段 一般为前后的递推主参数2.交叉路口是什么 (可选则的是什么)for循环用3.每个交叉路口可供选择的集合是什么 模拟要自己处理准备个阶段的集合4.终止条件是什么5.需不需要标记 需不需要去标记6.需不需要存...原创 2021-03-04 11:49:32 · 229 阅读 · 1 评论 -
pat 冬季第4题
掏钱买的考了一下最后一个题目大半天编一点编一点的感觉总是到不了头就睡觉去了 太困了 然后又搭上了晚上 看别人的总感觉思路虽然差不多但是我们实际处理差距还是很大的所以自己debug自己的代码 最后过了样例 感觉应该是对的不想再花一份钱弄一下了 有钱的老哥帮我弄一下看看对不对告诉我一下呗C:\Users\Administrator\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\TempState\Downloads\P...原创 2021-03-03 22:30:52 · 251 阅读 · 1 评论 -
pat 14复习必记模板
1、连通分量 图树 最深根1021#include<bits/stdc++.h>using namespace std;vector<int> ans1;int maxle=-1;vector<int> aa[10010];int visit[10010];void dfs(int root,int le){ //end visit[root]=1; if(le>maxle){ maxle=le;//maxle忘记更新 ans1原创 2021-02-27 17:41:04 · 213 阅读 · 1 评论 -
pat 复习 13 字符串处理剩余
//1082 挺复杂的字符串处理 #include<bits/stdc++.h>using namespace std;string numw[] ={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};string danwz[] ={"ge","Shi","Bai","Qian","Wan","Yi"};int a[]={1,10,100,1000,10000,100000,1000000,10000000,10000.原创 2021-02-20 23:52:48 · 327 阅读 · 0 评论 -
pat 复习 12 字符串处理
1001#include<bits/stdc++.h>using namespace std;int main(){ long long _1,_2,_3; scanf("%lld%lld",&_1,&_2); _3=_1+_2; string _4=to_string(_3); reverse(_4.begin(),_4.end()); int cnt=0; string ans=""; for(int i=0;i<_4.size();i++){原创 2021-02-19 22:55:57 · 201 阅读 · 0 评论 -
pat-复习10 11 平方映射 堆排序 归并排序 快速排序 直接插入排序的比较 二分查找
平方映射//1078 平方探测 #include<bits/stdc++.h>using namespace std;bool isprime(int n){ if(n<=1) return false; for(int i=2;i<=sqrt(n*1.0);i++){//<= 4.5 4本来可以<就漏掉了 if(n%i==0) return false; } return true;}int main(){ int ms,n,_1; s原创 2021-02-18 23:01:30 · 171 阅读 · 0 评论 -
pat-复习09 分数四则运算最后一道 素数 素因子分解 two pointer 链表
//1088 特意提到long int 相乘有可能超范围,所以当浮点错误时改用long long试一试 #include<bits/stdc++.h>using namespace std;int gcd(long long int a,long long int b){ if(b==0) return a; else gcd(b,a%b);}struct fra{long long int up,dowm;};fra reduction(fra a){ if(a.dow.原创 2021-02-16 23:48:40 · 169 阅读 · 0 评论 -
pat-复习08 大整数相加 分数运算部分
//1024 既然已经注意到是大整数相加了下面还用int 求和 to_string 这合适吗,不合适,数组也可以reverse 大整数相加千万不要在中途中再用整数赋值 否则大整数就白写了 #include<bits/stdc++.h> using namespace std; struct bign{ int d[1000]; int len; bign(){ memset(d,0,sizeof(d)); len=0; } }; /*bign ...原创 2021-02-16 00:16:36 · 1224 阅读 · 2 评论 -
pat-07排序部分stl应用
//1022 #include<bits/stdc++.h>using namespace std;//除了要注意换行符的吸收 还有注意年份的格式是%04d 编号的输出格式是%07d容易遗忘 map<string,set<int>>booktitle,author,keyword,publiser;//输出格式问题最后一定要点出来 map<int,set<int>>year; int main(){ int n; sca.原创 2021-02-14 23:10:20 · 105 阅读 · 0 评论 -
pat -06复习 并查集部分 以及排序前三道
//1118 并查集 #include<bits/stdc++.h>using namespace std;int fa[10009];int find(int x){ int a=x; while(x!=fa[x]){ x=fa[x]; } while(a!=fa[a]){ int z=a; a=fa[a]; fa[z]=x; } return x;}void unionn(int a,int b){ int f1=find(a); int .原创 2021-02-13 21:40:35 · 178 阅读 · 1 评论 -
pat-05复习 图部分剩余
//1111 //测试点二有问题 #include<bits/stdc++.h> using namespace std; vector<int> pred[510],pret[510],temp,temp1,ansd,anst; int distd[510],distt[510]; int a[510][510],t[510][510],visit1[510],visit2[510]; const int inf=1000000000; int ss,min..原创 2021-02-12 21:38:14 · 999 阅读 · 2 评论 -
pat-树剩余图部分03 04
//1009#include<bits/stdc++.h>using namespace std;struct node{int key,le,index; }; vector<int> in,post; vector<node> pre,lev[35]; int maxle=0; void dfs(int root,int inll,int inrr,int index,int le){ //end if(inll>inrr) re.原创 2021-02-10 23:07:30 · 184 阅读 · 0 评论 -
pat-树部分02
//1094#include<bits/stdc++.h>using namespace std;vector<int> v[110];int book[110] ;int maxle=0;void dfs(int root,int le){ //end book[le]++; if(v[root].size()==0){ if(le>maxle){ maxle=le; } return; } for(int i=0;i<v[ro.原创 2021-02-08 23:40:53 · 133 阅读 · 0 评论 -
pat 二刷树部分-01
//pat-143#include<bits/stdc++.h>using namespace std;vector<int> pre;map<int,int>ex;void lca(int a,int b){ int i=0; if(ex[a]==0&&ex[b]==0){ printf("ERROR: %d and %d are not found.\n",a,b); return; } else if(ex[a]==0){.原创 2021-02-07 22:46:30 · 167 阅读 · 0 评论