PAT
ZMST
这个作者很懒,什么都没留下…
展开
-
PAT——A1094 The Largest Generation(树的遍历,DFS)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>u原创 2018-08-31 09:59:51 · 134 阅读 · 0 评论 -
PAT——A1053 Path of Equal Weight
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<queue>原创 2018-08-31 19:27:05 · 160 阅读 · 0 评论 -
PAT——A1063 Set Similarity
题目链接:#include<bits/stdc++.h>using namespace std;#define maxn 51set<int> number[maxn];void compare(int a,int b){ int totalNum=number[b].size(),sameNum=0; for(set<int>:...原创 2018-08-24 19:15:53 · 109 阅读 · 0 评论 -
PAT——A1100 Mars Numbers(map)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<map>using namespace std;string st1[原创 2018-08-24 21:30:27 · 160 阅读 · 0 评论 -
PAT——A1102 Invert a Binary Tree(invert反转 + 遍历)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<stack>#include<queue>using namespace std;#define原创 2018-08-29 10:45:38 · 154 阅读 · 0 评论 -
PAT——A1081 Rational Sum(分数加法)
题目链接:#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;typedef long long ll;struct number{ ll fz; ll fm;};ll gcd(int a,i...原创 2018-08-29 13:46:27 · 221 阅读 · 0 评论 -
PAT——A1088 Rational Arithmetic(分数)
题目链接:#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;typedef long long ll;struct number{ ll fz,fm;}a,b;ll gcd(ll a,ll b){...原创 2018-08-29 15:21:58 · 168 阅读 · 0 评论 -
PAT——1054 The Dominant Color(map)
题目链接:一开始最后一个代码过不了 显示段错误,不懂呀可能是输入的数字过大,导致内存超限了#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include...原创 2018-08-25 10:38:32 · 146 阅读 · 0 评论 -
最大公约数
正整数a与b的最大公约数是指a与b的所有公约数中最大的那个公约数一般用gcd(a,b)来表示a和b的最大公约数而求解最大公约数常用欧几里得算法(即辗转相除法)【定义】设a、b均为正整数,则gcd(a,b)=gcd(b,a%b)【注意】0和任意一个整数a的最大公约数都是a(不是0)int gcd(int a,int b){ if(b==0) ...原创 2018-08-28 21:10:35 · 322 阅读 · 0 评论 -
PAT——A1078 Hashing(hash 素数)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<queue>原创 2018-08-31 16:52:43 · 206 阅读 · 0 评论 -
PAT——A1015 Reversible Primes(radix进制)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<queue>原创 2018-08-31 16:08:39 · 115 阅读 · 0 评论 -
PAT——A1106 Lowest Price in Supply Chain(树 DFS)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>u原创 2018-08-31 10:50:09 · 132 阅读 · 0 评论 -
PAT——A1008Elevator(模拟)
题目链接:#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>using namespace std;int a[110];int main(){ int n; scanf("%d",&n); int now=0,fl...原创 2018-08-28 15:38:28 · 188 阅读 · 0 评论 -
PAT——A1049 Counting Ones(数学问题)
题目链接:两个测试点超时22#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>using namespace std;int pd(int n){ int count=0; int t; while(n!=0) {...原创 2018-08-28 16:54:02 · 251 阅读 · 0 评论 -
PAT——A1004 Counting Leaves(树 DFS)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>u原创 2018-08-31 13:03:18 · 146 阅读 · 0 评论 -
PAT——A1039 Course List for Student(vector)
题目链接#include <bits/stdc++.h>using namespace std;const int M=26*26*26*10;vector<int> selectCourse[M];int getID(char name[]){ int id=0; for(int i=0;i<3;i++) { ...原创 2018-08-24 11:21:15 · 152 阅读 · 0 评论 -
PAT——B1013 数素数
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<queue>原创 2018-08-31 15:13:15 · 158 阅读 · 0 评论 -
PAT——A1007 素数对猜想
题目链接:一个测试点没过不知道为什么18'#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include&原创 2018-08-31 15:41:43 · 220 阅读 · 0 评论 -
PAT——A1047 Student List for Course(vector)
题目链接:#include <bits/stdc++.h>using namespace std;const int M=40010;const int T=3000;char name[M][5];vector<int> student[T];bool cmp(int a,int b){ return strcmp(name[a],name[b...原创 2018-08-24 15:14:40 · 129 阅读 · 0 评论 -
PAT——A1020 Tree Traversals(树)
题目链接:#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>#include<queue>using namespace std;#define maxn 50struct node{ int data; node* l...原创 2018-08-28 19:59:01 · 141 阅读 · 0 评论 -
天梯赛——名人堂与代金券(结构体)
题目链接:#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<iostream>#include<stack>using namespace std;typedef原创 2018-08-29 19:24:49 · 570 阅读 · 0 评论 -
天梯赛——福到了(模拟)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;int main(){ char c; int n; cin>>c>>n; getcha...原创 2018-08-29 20:06:28 · 568 阅读 · 0 评论 -
PAT——B A除以B(高精度除以低精度)
题目链接#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>#include<cstring>using namespace std;#define maxn 1010//nt r;str...原创 2018-09-03 10:40:34 · 426 阅读 · 0 评论 -
PAT——A1024 Palindromic Number(大数相加)
题目链接#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>#include<cstring>using namespace std;#define maxn 1010struct bign...原创 2018-09-03 15:50:01 · 165 阅读 · 0 评论 -
PAT——A1098 Insertion or Heap Sort(堆排序)
题目链接:#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>#include<cstring>using namespace std;const int maxn=111;int orig...原创 2018-09-03 18:55:21 · 237 阅读 · 0 评论 -
PAT——A1149(2018秋PAT甲级B题)
题目链接:再一次认识到自己与别人的差距明明结构体考试的时候自己也用了但是没有想到可以应一个bool型数组来遍历最后比较的时候逆向比较结构体数组就好了#include<cstdio>#include<iostream>#include<cstring>#include<vector>#include<cmath>...原创 2018-09-09 16:48:58 · 665 阅读 · 0 评论 -
PAT——A1148 Werewolf - Simple Version(2018PAT秋A题20")
题目链接:考试的时候一点思路都没有其实可以枚举就是只要枚举两个狼人的情况再判断这个是否正确即两种说谎情况①指证是狼人但是是民②指证是民但是是狼人然后两个说谎情况都要判断指证的人是狼还是民判断说谎的人数是否大于2#include<cstdio>#include<iostream>#include<map>#inclu...原创 2018-09-09 21:21:41 · 357 阅读 · 0 评论 -
PAT——A1153 LCA in a Binary Tree(2018秋PAT D题30")
题目链接:考试的时候只记得写遍历成二叉树但是题意竟然没看对卡了很久就是求最小祖宗再加一个DFS就好了呀#include<cstdio>#include<iostream>#include<cstring>#include<vector>#include<cmath>#include<algorit...原创 2018-09-10 09:33:05 · 244 阅读 · 0 评论 -
PAT——A1150Travelling Salesman Problem(2018秋PATC题25")
题目链接:emmm考试的时候以为是个图果断放弃其实就是道模拟题还是太菜了看懂题意先先找出输出的四种情况根据样例来判断①如果有相连的路不连通,不是环且输出NA②如果首尾不相同或者并没有经过每一个点(可以用set存储,相同的直接去掉,然后set容器的size如果不等于给出的值的个数)不是环【注意】set的作用:自动去重且按升序排序③遍历了的数的个...原创 2018-09-10 14:20:26 · 490 阅读 · 0 评论 -
PAT——A1017 Queueing at Bank
题目链接:#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>#include<cstring>#include<map>#include<queue>原创 2018-09-05 10:57:11 · 99 阅读 · 0 评论 -
PAT——A1105 Spiral Matrix
题目链接:#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>#include<cstring>#include<map>#include<queue>原创 2018-09-05 09:49:56 · 174 阅读 · 0 评论 -
PAT——A1107 Social Clusters(并查集)
题目链接:#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>using namespace std;#define maxn 1010int father[maxn];int isRoot[maxn]...原创 2018-09-02 13:31:51 · 144 阅读 · 0 评论 -
PAT——A1066 Root of AVL Tree(AVL)
题目链接:#include<cstdio>#include<iostream>#include<algorithm>#include<vector>using namespace std;struct node{ int v,height; node *lchild,*rchild;}*root;node* new...原创 2018-09-01 14:59:18 · 102 阅读 · 0 评论 -
PAT——A1071 Speech Patterns(map)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<map>using namespace std;map<原创 2018-08-25 20:00:31 · 109 阅读 · 0 评论 -
PAT——A1096 Consecutive Factors
题目链接:#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>using namespace std;typedef long long ll;int main(){ ll n; sca...原创 2018-09-01 20:10:17 · 156 阅读 · 0 评论 -
PAT——A1059 Prime Factors
题目链接:#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>using namespace std;#define maxn 100010typedef long long ll;bool is_pr...原创 2018-09-01 20:53:11 · 130 阅读 · 0 评论 -
PAT——A1013 Battle Over Cities(图的遍历)
题目链接:#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<vector>#include<cstring>#include<map>#include<queue>原创 2018-09-04 15:55:38 · 160 阅读 · 0 评论 -
PAT——A1057 Stack(分块思想 第K大)
题目链接:#include<cstdio>#include<iostream>#include<map>#include<set>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#原创 2018-09-04 19:32:56 · 280 阅读 · 0 评论 -
PAT——A1003 Emergency
题目链接:#include<cstdio>#include<iostream>#include<map>#include<set>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#原创 2018-09-04 20:23:02 · 311 阅读 · 0 评论 -
PAT——A1090 Highest Price in Supply Chain(树的遍历)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>using namespace std;#define maxn 100010vector&l...原创 2018-08-30 10:30:37 · 135 阅读 · 0 评论