
PAT
empty_coder
这个作者很懒,什么都没留下…
展开
-
1105. Spiral Matrix(25)
题目见这里 题意是比较清晰的,即给一串正数,按降序填充一个螺旋矩阵,矩阵大小取决于正数个数。 确定矩阵行和列很容易,主要是找到填充规律,我们借用下面的三张图很容易发现规律。 我们只要用turnH和turnV记载水平方向和竖直方向转换次数,并单独处理第一行和最后一个数就好啦。 代码如下:#include #include #原创 2017-07-13 13:04:11 · 315 阅读 · 0 评论 -
1031. 查验身份证(15)
题目链接:https://www.patest.cn/contests/pat-b-practise/1031 一个合法的身份证号码由17位地区、日期编号和顺序编号加1位校验码组成。校验码的计算规则如下: 首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; 然后将计算的和对11取模得到值Z;最后按照以下关系对应Z值与校验码M的...原创 2018-03-18 12:47:02 · 226 阅读 · 0 评论 -
To Buy or Not to Buy (20)
题目链接:https://www.nowcoder.com/pat/5/problem/4038 Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings o...原创 2018-03-09 17:46:42 · 261 阅读 · 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 评论 -
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 评论 -
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 评论 -
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 评论 -
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 评论 -
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 评论 -
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 评论 -
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 评论 -
1004. Counting Leaves (30)
原创 2018-05-09 15:08:29 · 175 阅读 · 0 评论