- 博客(20)
- 收藏
- 关注

原创 2019年12月7号冬季PAT甲级满分
没想到我也能写出这么硬气的标题,题目解析和我考场上写的ac代码传博客上了。倒着4-3-2-1做的,分别用时21,20,13,52。做完看的时候已经48个满分了,如果第一题getline没忘记格式应该能再快十几分钟。一点点小经验,希望能帮到有需要的人。算法笔记+刷官网题库不解释官网前面恶心的模拟题可以放低重心,重点关注后面的50道,更重要的是近几次的没扔到155题里的机试、最近的考试题,...
2019-12-08 04:10:12
961
1

原创 PAT甲级(Advanced)解题记录
PAT甲级(Advanced)解题记录历时:20190627-至今github代码仓库:传送门:地址按解题时间:blog记录按题目顺序:1001错误一个,记得考虑特殊情况0;1002错误一个,注意判断浮点数的时候,用差的绝对值比较呀fabs(coeff[i]-0.0)>10e-5漏掉了一个fabs导致一个用例一直错误。1003 dijkstra最短距离算法。用邻接表和邻接矩...
2019-07-27 13:34:22
372
原创 pi的数字飞花令的理论上限
11月底的一个电视节目,几位诗词大佬用pi的数字飞花令,对到了204位之长。如果收录所有的诗词,用算法筛选出来其中包含零、一、二…到九的诗句。对照pi的值,理论上能对到多少?[思考]:pi是无限的,诗词再多也是有限的,所以根据收录的库的规模,一定有一个理论上限。会出现的一个情况,一句诗词里包含多个数字,但是按照不能重复说的规则,这句诗词只能被用一次,也就是代表一个数字。优先使用只包含...
2019-12-14 13:10:48
388
原创 PAT-2019年冬季考试-甲级-7-4 Cartesian Tree (30分)
A Cartesian tree is a binary tree constructed from a sequence of distinct numbers. The tree is heap-ordered, and an inorder traversal returns the original sequence. For example, given the sequence { 8...
2019-12-08 02:54:31
287
原创 PAT-2019年冬季考试-甲级-7-3 Summit (25分)
A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is ...
2019-12-08 02:46:06
574
原创 PAT-2019年冬季考试-甲级-7-2 Block Reversing (25分)
Given a singly linked list L. Let us consider every K nodes as a block (if there are less than K nodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to re...
2019-12-08 02:39:08
422
原创 PAT-2019年冬季考试-甲级-7-1 Good in C (20分)
When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows?Input Specification:Each input file contains one test case. For each case, the first part giv...
2019-12-08 02:27:37
408
原创 1111 Online Map
1111 Online Map (30 分)题目地址优先队列(重载运算符)优化的dijkstra,route很精妙#include <stdio.h>#include <iostream>#include <vector>#include <queue>#define INF 0x3fffffff#define MAX 502usi...
2019-09-07 11:01:11
146
原创 某考研群的入群试题
题目描述:小翟为了完成一篇论文,一共要抄袭n篇文章。其中第i篇文章需要a[i]的时间去完成。小翟可以发动粉丝同时抄袭多篇文章,但存在一些文章,只有当它的若干个前置文章抄袭完成后,才能开始抄袭该文章。同时我们认为小翟和其粉丝在一篇文章的前置文章都完成后,能马上开始抄袭该文章。为了让小翟尽快完成论文,获得博士学位,在最优的情况下,小翟的论文什么时候可以完成?小翟虽然不知道知网,但是他想知道在保证论...
2019-08-30 10:20:20
1101
2
原创 求质数的个数
求1-n质数的个数,看不懂存一下代码:#include <cstdio>#include <cmath>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>#define ll long longusing nam...
2019-08-18 09:50:46
774
原创 中缀表达式转后缀表达式并计算
上次没做出来识别括号和小数。// 带括号的表达式识别计算。#include <stdio.h>#include <iostream>#include <stack>#include <string>#include <map>#include <cmath>using namespace std;struc...
2019-08-02 19:05:17
159
原创 1123 Is It a Complete AVL Tree
1123 Is It a Complete AVL Tree题目地址四种旋转:按照图的方向写:Figure 12为rightrotation和leftrotation。rlrotation和lrrotation,分别是先把根节点的右节点右旋再把根节点左旋转、先把根节点的左节点左旋再把根节点右旋转层次遍历的同时判断是否为完整二叉树当某一层没有左右子树(为NULL)时,激活标识afte...
2019-07-17 19:05:16
130
原创 算数的中缀表达式计算
中缀表达式:操作符在操作数中间;例如:1+2*3-4/5后缀表达式:操作符在操作数后面;例如:1 2 3 * 4 5 / - +后缀表达式的优点:按顺序读取,碰到操作数进栈;碰到操作符就把前面两个操作数弹出来计算,计算结果进栈;从中缀表达式到后缀表达式的变换:栈st1 和栈st2 ,st1 放操作符,st2 放操作数;遍历表达式字符串:遇到数字:压入st2;遇到操作符:压入st1中,但...
2019-07-11 19:19:30
491
原创 N皇后
递归求解#include <stdio.h>#define M 8int a[M][M]; bool check(int i,int j);void findQueen(int i);void printQueens();int sum;int main() { sum=0; findQueen(0); printf("%d",sum); }void...
2019-07-09 00:12:10
136
原创 1038 Recover the Smallest Number
1038 Recover the Smallest Number题目地址思路:直接按位排序,对不同长度的字符串分情况讨论(从没写过这么长的cmp函数)坑:测试点2 全部都是0;因为输出最终数字的时候开头的0不输出,所以设立一个标志位检测省略过开头的0没,什么都没输出(全部省略)就再补充一个0AC代码:#include <stdio.h>#include <str...
2019-07-06 14:15:50
470
原创 1064 Complete Binary Search Tree
1064 Complete Binary Search Tree题目地址完全二叉树和二叉搜索树结合聪明办法:#include <stdio.h>#include <string.h>#include <vector>#include <math.h>#include <algorithm>#include <que...
2019-07-02 16:16:57
428
原创 算法笔记学习&&PAT甲级解题记录
算法笔记学习记录2019.06.26float&&double推荐全部使用double,注意区分scanf("%lf",&double1);与printf("%f",double1);分清%md,%0md,%.md以及可以合用%n.mdgetchar()&&putchar()getchar可以识别换行符\nbd>Ctrl/Co...
2019-07-02 00:53:25
723
原创 计算两个日期的相邻时间
##问题A 日期差值题目链接来源codeup计算两个日期的相邻时间注意坑点:闰年的判断,4,100,400;如果统一到距离00010101的日期,注意当前年是闰年时,算月份和日期时考虑2月29。AC 代码:#include <stdio.h>#include <string.h>#include <math.h>#include <...
2019-06-30 12:16:58
1008
原创 问题 B: A+B【字符串处理去掉数字之间的,】
题目链接题目描述给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号","隔开。现在请计算A+B的结果,并以正常形式输出。输入输入包含多组数据数据,每组数据占一行,由两个整数A和B组成(-10^9 < A,B < 10^9)。输出请计算A+B的结果,并以正常形式输出,每组数据占一行。样例输入-234,567,890 123,456,7891,234 2,34...
2019-06-28 10:50:15
152
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人