
PAT
从小处着笔,各个击破!
empty_coder
这个作者很懒,什么都没留下…
展开
-
1004. Counting Leaves (30)
原创 2018-05-09 15:08:29 · 175 阅读 · 0 评论 -
1015. Reversible Primes (20)
题目链接:https://www.patest.cn/contests/pat-a-practise/1015时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA reversible prime in any number system is a prime whose "reverse" in that number syste...原创 2018-02-17 20:48:23 · 280 阅读 · 0 评论 -
1101. Quick Sort (25)
时间限制:200 ms 内存限制:65536 kB 代码长度限制:16000 B 判题程序:Standard 作者:CAO, Peng There is a classical process named partition in the famous quick sort algorithm. In this proce原创 2017-09-03 01:24:54 · 271 阅读 · 0 评论 -
1105. Spiral Matrix(25)
题目见这里 题意是比较清晰的,即给一串正数,按降序填充一个螺旋矩阵,矩阵大小取决于正数个数。 确定矩阵行和列很容易,主要是找到填充规律,我们借用下面的三张图很容易发现规律。 我们只要用turnH和turnV记载水平方向和竖直方向转换次数,并单独处理第一行和最后一个数就好啦。 代码如下: #include #include #原创 2017-07-13 13:04:11 · 315 阅读 · 0 评论 -
1106. Lowest Price in Supply Chain(25)
题目见https://www.patest.cn/contests/pat-a-practise/1106有点类似邻接表,只不过边表采用队列的形式,然后就是在遍历的过程中递归啦代码如下:#include <stdio.h> #include <stdlib.h> #include <math.h> #define N 100005typedef struct{ int front,rear;原创 2017-07-15 00:54:39 · 514 阅读 · 0 评论 -
1108. Finding Average (20)
题目见这里 20分的题目,怎么我花的时间比30分的都长,渣渣如我,都快弄不清正式考试的时候是先做20分的题目还是先做30分的题目呢,QAQ。 言归正传,这其实是一个普通的字符串处理题目,和PAT(Advanced Level)其他题目一样,并没有什么实质的难度,主要注意下面5个细节: 1). 合法字符串最长为8位(-1000.00) 2). 只有一个符号的判断 3). 整数位(>2位时)是否有原创 2017-07-17 12:26:50 · 309 阅读 · 0 评论 -
1109. Group Photo (25)
题目见这里 实际上是结构体的排序,然后按特定规则重新填充 代码如下:#include <stdio.h> #include <string.h> #include <stdlib.h> #define N 10005typedef struct{ int height; char name[9]; }People;People people[N],tmp[N]; int n,原创 2017-07-21 08:29:51 · 397 阅读 · 0 评论 -
1110. Complete Binary Tree (25)
题目见这里 完全二叉树的判定而已,采用层次遍历,访问到某个结点时查探它的左右孩子情况;另外就是注意数据读入,有可能为两位(至多两位)代码如下: #include <stdio.h> #define N 21typedef struct{ int lChild,rChild; }BiTree;int n,root; BiTree bt[N];void Read(){ int fla原创 2017-07-22 21:31:29 · 312 阅读 · 0 评论 -
1112. Stucked Keyboard (20)
题目见这里 1). 无重复从前往后输出stucked key(字符仅出现k次) 2). 原字符串每k个连续的stucked key只取1个,输出新的字符串 一共37种字符,主要是下面4个数组的使用 1) f[37]:统计某个字符连续出现的个数,具有时效性 2) f1[37]:统计stucked key连续出现的组数 3) flag[37]:stucked key是否存在 4) out[37]原创 2017-07-23 23:58:22 · 322 阅读 · 0 评论 -
1113. Integer Set Partition (25)
题目见这里 一个一看就会的题目 代码如下: #include <stdio.h> #include <stdlib.h> #define N 100005 int Cmp(const void *a, const void *b){ return *(int *)b - *(int *)a; }int main(){ // freopen("Data.txt","r",stdin);原创 2017-07-24 13:30:23 · 245 阅读 · 0 评论 -
1115. Counting Nodes in a BST (30)
题目见这里BST结构体中add一个level变量,创建BST时,需要在add结点之前根据将来的父结点得到该结点的level值,然后就是LevelOrder了,从后往前扫描bstQ(结点队列)即可 代码如下: #include <stdio.h> #include <stdlib.h> #define N 1005 typedef struct node{ int level; int原创 2017-07-24 13:44:40 · 298 阅读 · 0 评论 -
1124. Raffle for Weibo Followers (20)
题目见这里 用链表保存Followers,每个插入链表的对象对应一个flag(初值为false),必须输出对象后flag才能置为true,注意每次输出必须保证minclude include using namespace std;const int M = 1005;int main(){ // freopen(“Data.txt”,”r”,stdin); list forwards原创 2017-08-09 13:40:26 · 291 阅读 · 0 评论 -
1126. Eulerian Path (25)
题目见这里 主要是邻接链表+dfs或并查集判断无向图的连通性,然后结合度的情况判断图的种类 邻接链表+dfs #include <cstdio> #include <iostream> #include <list>using namespace std;const int N = 505;void Read(int &vertices, int &edges, int *degrees, list原创 2017-08-12 12:46:15 · 311 阅读 · 0 评论