自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(40)
  • 收藏
  • 关注

原创 PAT刷题日志

2020-05-10: 调整刷题策略:集中精力刷《算法笔记》第四章的题目,夯实基础。基础实在太差,第八章之后的题目压根就不会,做题的时候就是抄一遍代码,理解一遍代码,根本不能算作刷题,而是被题刷。 之前一个知识点一道题的方法根本就是走马观花,蜻蜓点水,抄一遍代码就觉得会了,第二天就忘干净了 两个字来形容:浮躁 ...

2020-05-10 21:05:45 271

原创 ASP.NET Core SignalR 入门 添加 SignalR 客户端库 找不到目录

解决方案:科学上网,全局模式。

2024-01-15 09:01:20 543

原创 PAT刷题-排序:1016 Phone Bills

过一个测试点就15分了...... 搞了一上午,搞出个15分,本以为一分也拿不到 思路跟《算法笔记》完全不一样,今天这道题就到这儿,明天再修改,花时间有点多了 #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef struct { bool on_off_line;//1-在线,0-离线 int time, month,date

2020-05-25 13:44:48 220

原创 PAT刷题-排序:1012 The Best Rank

先占坑,明天再写总结,现在十点半,太晚了 #include<cstdio> #include<algorithm> using namespace std; typedef struct { int id; int score[4];//0-A,1-C,2-M,3-E } Student; int now; int r[1000000][4] = {0}; char course[4] = {'A', 'C', 'M', 'E'}; bool ..

2020-05-24 22:29:19 285

原创 PAT刷题-排序:1062 Talent and Virtue

巧记排序函数:标准库的sort()函数,保证排序后,数据的顺序与排序函数中的不等关系一致(好像也不巧) #include<iostream> #include<algorithm> using namespace std; typedef struct { long int ID_Number; int Virtue_Grade, Talent_Grade, Total_Grade, type; } Man; bool cmp(Man m1,Man .

2020-05-23 21:19:16 312

原创 动态分配线性表的顺序存储(Sequence List)

遗留问题: 3213 3

2020-05-10 21:36:50 334

原创 PAT 1056 Mice and Rice(Re)

#include<cstdio> #include<queue> using namespace std; typedef struct{ int rank; int weight; } Mice; int main() { int Np, Ng, i, j, temp, remain, group, max; queue<int> qint; Mice mice[1024]; scanf("%d%d", &amp.

2020-05-10 20:56:00 114

原创 静态分配线性表的顺序存储(Sequence List)

#include<cstdio> using namespace std; #define MaxSize 100 typedef struct { int data[MaxSize]; int length; } SeqList; //遗留问题:使用位序还是次序?这里使用的是位序 void InitList();//初始化线性表:构造一个空的线性表 int Length(SeqList &seqlist);//求表长:返回线性表中元素的个数 int Loca.

2020-05-09 22:26:33 282

原创 PAT 1051 Pop Sequence(Re)

最危险的地方,就是最安全的地方;最安全的地方,就是最危险的地方。 今天开始重新刷PAT,之前的基本忘干净了 决定先从堆栈这部分开始,然后树...... 然后上来这题就给我撂这儿了 #include<cstdio> #include<stack> using namespace std; int main() { int m, n, k, i, iter; int seq[1024]; bool flag; stack<int&g..

2020-05-09 20:42:45 202

原创 PAT甲级索引

按题型整理 按顺序整理

2020-05-09 20:08:08 151

原创 已知a,b,求x1,x2使得x1+x2=a,x1*x2=b

构造法(加减零,乘除一) import math #输入两个整数a和b a = int(input()) b = int(input()) # 请在此添加代码,要求判断是否存在两个整数,它们的和为a,积为b; #********** Begin *********# x1 = int(float(a+math.sqrt(a**2-4*b))/2) x2 = int(float(...

2020-05-08 15:12:49 931

原创 对GBN协议的一些理解

王道书上的讲解不清楚,包括王道网课(2020)讲得也不清楚。 自己试着讲一下为什么窗口最大值 ≤ 2 (e^n) - 1 设用2个比特给帧编号:00、01、10、11 则帧序列为 [ 0,1,2,3 ],[ 0,1,2,3 ]... ...以此循环 那么按照公式,滑动窗口最大值为:3 假设发送窗口的大小为 4 如果第一个窗口发送的 0 1 2 3 号的确认帧全部丢失(即接收方收到...

2020-05-07 23:19:58 1591

原创 PAT-A刷题::1066 Root of AVL Tree——二叉平衡树(AVL树)

抄代码还能抄歪来...... #include<cstdio> #include<algorithm> using namespace std; struct Node { int v, height; Node *leftchild, *rightchild; }; Node* newNode(int v) { Node *node ...

2020-03-23 21:30:50 170

原创 PAT-A刷题::1043 Is It a Binary Search Tree

稍微熟悉一些二叉树的相关知识的话,这个题应该不算难。 我犯的第一个错误非常低级,递归调用了错误的函数,比如说PostOrderMirror(BST*root)函数中应该调用PostOrderMirror(BST*root),而我却调用了PostOrder(BST*root)。每个递归函数我都写错了...... 第二个错误,也比较低级,用于输出的print(BST*root...

2020-03-21 21:59:14 148

原创 PAT-A刷题::1053 Path of Equal Weight

刷题俩月,今天终于感觉到了进步提高篇的题目。 提高篇的题目,大致思路能跟得上了,比如说,这题使用DFS而不是BFS。 细节方面还是差些火候,比如对孩子节点进行排序,题目要求按照权值按非递增的顺序输出;还有,开始是想用队列记录节点值,搞了一会发现队列的性质(头删尾增)不允许。 另外就是,PAT刷题配合初试复习效果很好。 #include<cstdio> #include&l...

2020-03-14 18:39:35 115

原创 PAT-A刷题::1020 Tree Traversals

shift+enter:vscode快速输入 #include<cstdio> #include<queue> #define I 31 using namespace std; int n; int pre[I], in[I], post[I]; struct Node{ int data; Node *left = NULL, *right ...

2020-03-13 18:51:18 144

原创 PAT-A刷题::1091 Acute Stroke

写注释的过程,同样也是“李姐”的过程 加强英文阅读能力 渐渐意识到,PAT的难度不仅在于题目本身,还在于题目是以纯英文给出的 对此题来说,它对问题的抽象与上一篇博文相差无几 但我在读题干的过程中就是看不出它要表达什么意思 直到看了书的中文讲解...... #include<cstdio> #include<queue> using n...

2020-03-11 21:41:08 138

原创 广度优先搜索(Breadth First Search)

因为今天考研复习进度里边正好看到树的层次遍历 个人理解,广度优先搜索也可以看成是树的层次遍历 所以广度优先搜索理解起来要比深度优先搜索更容易一些 解题思路:对矩阵中元素为1的位置,检索其上下左右四个位置 #include<cstdio> #include<queue> /* 测试样例 6 7 0 1 1 1 0 0 1 0 0 1 0 0 0 0 0...

2020-03-09 20:35:36 147

原创 PAT (Advanced Level) Practice::1103 Integer Factorization

#include<cstdio> #include<vector> #include<algorithm> using namespace std; /* 把n分解为k个关于p的指数之和 N = n[1]^P + ... n[K]^P */ int k, n, p, maxFacSum = -1; vector<int> fac, ans, tem...

2020-03-06 21:02:25 173

原创 深度优先搜索(DepthFirstSearch,DFS)

问题名称都是自己起的,存在不严谨之处请斧正。 背包问题 : version1:朴素版本 #include<cstdio> /* 测试用例 5 8 3 5 1 2 2 4 5 2 1 3 */ const int maxn = 30; int n, V, maxValue = 0;//物品数量,背包容量,最大价值 int w[maxn], c[maxn];//每件物品的重...

2020-03-05 21:19:56 194

原创 PAT (Advanced Level) Practice::1032 Sharing

总算做到一道比较简单的题了....... 易错点: scanf("%d%c%d",&temp,&data,&next);注意格式化字符串里的空格,这样可以跳过输入的空格。做题过程中忘记可以这样写,然后用了cin代替 printf("%05d",second);依然是格式化字符串里,要用%05d,输出不足五位补0 另外看到一个优秀的...

2020-03-02 20:38:27 146

原创 PAT (Advanced Level) Practice::1056 Mice and Rice

提高篇的题目,难度都很高唉,这题都没耐心读懂题目,就看答案了 收获:利用队列进行多个分组的最值的判定 有点归并查找的意思?我写了一个demo巩固这次所学,放到下方 #include<cstdio> #include<queue> #define mx 1024 using namespace std; struct Mice { int weigh...

2020-03-01 21:40:14 170

原创 PAT (Advanced Level) Practice::1051 Pop Sequence

我用的方法是:边输入,边比较判断 这真是一道好题,做完这题才发觉自己的渺小 #include<cstdio> #include<stack> #define mx 1024 using namespace std; int main() { int m, n, k, i, point; int str[mx]; bool flag; ...

2020-02-29 17:19:30 175

原创 PAT (Advanced Level) Practice::1100 mars numbers (20分)

自己写的版本停滞在了16分,拔不上去了,所以照着书敲一遍作者写的代码 打表 这是我之前有意略过的一个知识点 本题一共170种可能,直接把所有可能全部存到一个变量里,然后检索输出就行 #include<cstdio> #include<iostream> #include<string> #include<map> using name...

2020-02-25 16:45:23 184

原创 PAT (Advanced Level) Practice::1060 Are They Equal

算法笔记里对这道题的讲解实在是难以咀嚼,所以先把代码放上来,再通过思维导图的方式捋一遍 #include<iostream> #include<string> using namespace std; int n;//有效位数 string deal(string s,int &e) { int k = 0;//s的下标 int num...

2020-02-24 14:48:38 132

原创 PAT (Advanced Level) Practice::1039 Course List for Student

这题与其说考察vector,倒不如说考察哈希 思考过程中有想到用哈希,但是看到这一题分类到了vector小节下,这个想法就飘走了 映射的计算方法,要进位 输出课程号的时候要排序,否则会有两个点过不了 #include<cstdio> #include<vector> #include<algorithm> #define M 26*26*26...

2020-02-23 15:37:44 142

原创 PAT (Advanced Level) Practice::1063 Set Similarity

使用 unordered_set 代替set 使用scanf代替cin static_cast<double>:显式转换 使用static_cast可以明确告诉编译器,这种损失精度的转换是在知情的情况下进行的,也可以让阅读程序的其他程序员明确你转换的目的而不是由于疏忽。   把精度大的类型转换为精度小的类型,static_cast使用位截断进行处理。 容器...

2020-02-22 15:22:27 170

原创 PAT (Basic Level) Practice::1017 A除以B

高精度整数运算的题目,根本没有头绪,还想着把长数据拆成短数据,算完短数据之后再把它们合并起来 书上的方法是模拟手工运算,我也是看了一遍它的代码后,自己写的一遍 我尤其不喜欢函数调用、结构体(这是个坏习惯),所以书上代码里用的函数全部拆开,放到main()里 in my opinion,传值调用就是眼中钉、肉中刺,然而全部展开之后并没有看到多大的性能提升 #include&lt...

2020-02-20 16:32:28 105

原创 PAT (Advanced Level) Practice::1059 Prime Factors

第三个测试用例的 N 值为1 格式是 x = f(x),调试的三分之一时间都忽略了要输出前边的 x 代码的长度与效率不呈正相关 #include<iostream> #define limit 100101 using namespace std; struct Factor { int num = 0; int count = 0; }; in...

2020-02-19 15:04:47 153

原创 PAT (Basic Level) Practice::1013 数素数

需要注意的地方: 输入是序数,而不是界限 第一万个素数是:104729,所以上限要开的足够大 输出的时候使用的迭代变量要统一 #include<iostream> #define L 1024000 using namespace std; int main() { int n, m, cnt = 0; bool b[L]{false}; i...

2020-02-18 15:43:42 192

原创 PAT (Basic Level) Practice::1008 数组元素循环右移问题

重点注意的就是M这个数,它是可以大于N的 《算法笔记》里采用比较复杂的方式,应该是为了说明“如何使移动次数最少?”这个问题 但是目前还用不到这个知识,暂且搁置,碰到类似问题再回来研习 现在只觉得自己写出了比书上更简洁的代码(narcissist)哈哈哈哈哈哈哈哈哈哈 #include<iostream> using namespace std; int main() { ...

2020-02-17 14:37:39 138

原创 PAT (Advanced Level) Practice::1081 Rational Sum

收获:递归法得求最大公约数m,最小公倍数就是a*b/m 变量名字,在清晰易懂的基础上,能短就短 #include<iostream> #include<cmath> using namespace std; struct RationalNumbers { long long numerator; long long...

2020-02-16 19:53:49 146

原创 PAT (Basic Level) Practice::1003 我要通过!

此题核心是找到三个位置(xPyTz)的A的数量关系 半个月之前做过一次,当时做不出来就放下了,后两个条件真的难懂...... 自己写代码的时候,xyz三个数值在每次迭代的时候要更新 另外,不仅像书里说的,z-(y-1)*x==x,还要 y!=0 作为判定条件 #include<iostream> using namespace std; bool con1(const...

2020-02-16 15:38:39 166

原创 PAT (Advanced Level) Practice::1069 The Black Hole of Numbers

自己觉得,相比算法笔记书里的代码,我的代码通过调用一次排序函数,确定两个数值实现了更快的速度。 注意点:读入 的数据是四位没错,但要注意格式,“0586”是四位,“1635”也是四位,忽略这个点就会有三个点超时,只有14分。 所以,我的做法是先将数值读入,再把它分解到int数组里。 #include<iostream> #include<algorithm&gt...

2020-02-14 18:41:30 197

原创 PAT (Advanced Level) Practice::1085 Perfect Sequence

三种思想,实现了两种 1.二分法 #include<iostream> #include<algorithm> #define M 102400 using namespace std; int main() { int n, p, j, mx = 1, temp = 0; int str[M]; cin >> n &gt...

2020-02-13 21:09:40 145

原创 PAT (Advanced Level) Practice::1033 To Fill or Not to Fill(区间贪心)

#include<iostream> #include<algorithm> using namespace std; struct Gastation { double price;//油价 double distance;//距离杭州的距离 }; bool cmp(Gastation &g1,Gastation &g2) { ...

2020-02-10 17:56:47 210

原创 PAT (Basic Level) Practice::1020 月饼

#include<iostream> #include<algorithm> using namespace std; const int MAX = 10240; struct Cake { double amount;//attention:set 'amount' to type double double total_price; dou...

2020-02-09 15:29:57 115

原创 PAT (Advanced Level) Practice::1084 Broken Keyboard

先说下自己的思想:对于两行字符串a,b,设定两个迭代器(分别为i,j),以单词为单位判断缺失的字符。两个迭代器以异步方式递增,每当遇到迭代器指向的元素a[i]!=b[j],就将a[i]列为目标字符。 #include<iostream> #include<cstdio> #include<cstring> #include<ctype.h> us...

2020-01-31 16:20:21 194

原创 PAT::1005 继续(3n+1)猜想

#include<iostream> #include<set> using namespace std; int main() { int n = 0, tar = 0, temp = 0, size = 0; set<int> v; cin >> n; for (int i = 0; i < n;i++...

2020-01-11 10:26:46 122

原创 PAT (Basic Level) 刷题-1002:读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字

搞了很长时间,第二个测试就是过不去 好想知道他的测试用例是啥啊!!!!!郁闷 跪求好心人斧正!!! 然后这是我的代码: #include<iostream> using namespace std; int main() { string n; string s[10]{"ling","yi","er","san","si","wu","liu","qi",...

2019-10-25 21:48:05 3139 3

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除