![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PTA
Liberalspirit
这个作者很懒,什么都没留下…
展开
-
A1045 Favorite Color Stripe (30分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-07-13 15:02:05 · 135 阅读 · 0 评论 -
A1087 All Roads Lead to Rome (30分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-07-10 23:57:03 · 184 阅读 · 0 评论 -
A1072 Gas Station (30分)
常规的图的Dijkstra求最短路径的方式但是需要对题目有写理解以及稍微处理一下数据,注意一点细节。。。pat不能速成。。况且基础我还不好。刷的时候还是有点难受的。。硬学关于strToNum的方法也很多细节都写错了。。比如s[i]-‘0’(没有转成字符串),判断s[0]=‘G’的时候写成了s[1]所以可以看到有很多的测试输出。。。我早晚死在自己造的坑上计算平均值两种方法均可:直接计算。累加后/n计算都行#include<cstdio>#include<stdlib.原创 2020-07-10 22:25:27 · 159 阅读 · 0 评论 -
A1018 Public Bike Management (30分)
注意点:如下错误是因为他要求的调整是从0沿着最优路径到终点沿着顺序跳转例如:因此最开始的做法是直接算出最优路径的bike的数量再减去整条路径的节点都达到完美的时候需要的bike获得的差值是需要send的自行车,如果差值<0 那么就应该送回back自行车,而send 为0:但是很显然上面的例子就不符合所以用这样的方法:给出错误代码:会导致最终的测试点有两个过不去#include<cstdio>#include<stdlib.h>#inclu...原创 2020-07-09 17:23:50 · 221 阅读 · 0 评论 -
A1003 Emergency (25分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-07-09 10:21:42 · 154 阅读 · 0 评论 -
A1021 Deepest Root (25分)
运行超时的代码以及算法优化的代码:运行超时:#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>原创 2020-07-08 00:39:02 · 124 阅读 · 0 评论 -
A1013 Battle Over Cities (25分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-07-07 20:58:25 · 127 阅读 · 0 评论 -
A1098 Insertion or Heap Sort (25分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-07-05 22:12:04 · 1704 阅读 · 0 评论 -
A1066 Root of AVL Tree (25分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-07-04 21:52:07 · 160 阅读 · 0 评论 -
A1064 Complete Binary Search Tree (30分)
有疑问:这个在dev C++中编译不会出问题,但是在pat里会报编译错误:#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#inclu原创 2020-07-04 15:34:00 · 144 阅读 · 0 评论 -
先序中序求后序/先序中序求层序/后序中序求先序/后序中序求层序(不用构造二叉树)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-07-01 13:16:16 · 320 阅读 · 0 评论 -
先序,后序,层次分别和中序序列创建二叉树(层次遍历方法遍历二叉树)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-07-01 10:30:01 · 851 阅读 · 0 评论 -
A1091 Acute Stroke (30分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-06-30 12:56:28 · 177 阅读 · 0 评论 -
1103 Integer Factorization (30分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-06-29 23:48:28 · 183 阅读 · 0 评论 -
A1097 Deduplication on a Linked List (25分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-06-29 14:18:05 · 163 阅读 · 0 评论 -
A1052 Linked List Sorting (25分)
#include<cstdio>#include<stdlib.h>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<map>#include<queue>#include<stack>#in.原创 2020-06-29 11:53:11 · 141 阅读 · 0 评论 -
1100 Mars Numbers (20分)
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<vector>#include<set>#include<map>#include<string>using namespace std;string u.原创 2020-05-21 14:52:57 · 107 阅读 · 0 评论 -
1059 Prime Factors (25分)
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<map>using namespace std;const int maxn=100100;typedef long long ll;bool Hash[maxn]={0};int isPr.原创 2020-05-19 14:16:43 · 143 阅读 · 0 评论 -
1096 Consecutive Factors (20分)
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<map>using namespace std;const int maxn=10010;typedef long long ll;bool Hash[maxn]={0};int isPri.原创 2020-05-19 12:28:08 · 129 阅读 · 0 评论 -
A1029
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<set>#include<map>using namespace std;typedef long long ...原创 2020-05-03 23:10:44 · 135 阅读 · 0 评论 -
B1030 完美数列 (25分) & A1085 Perfect Sequence (25分)
有一个例子过不了,不知道为什么。。。不可过:使用two pointers#include<iostream>#include<cstdio>#include<math.h>#include<cstring>#include<algorithm> #include<cctype>using namespac...原创 2020-03-12 19:21:16 · 108 阅读 · 0 评论 -
A1044 Shopping in Mars (25分)
下面是正确的代码二分查找法查出来的如果right没有进行替换就直接返回n的时候,可能之后算出的temp值会小于m,所以要多加一条temp>=m时才进行最接近值的替换,算出来的最接近值才是对的。#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h&g...原创 2020-03-12 18:15:43 · 122 阅读 · 0 评论 -
A1010 Radix (25分)
有个疑问:cin和scanf是不能混用吗?为什么呢?是末尾会有什么符号的关系吗?找了我半天,每次都是细节。。。一不注意,思路就断开,细节就乱了,基础不好就开始各种迷惑。总体思路还好。。果真程序和做数学题不一样。#include<iostream>#include<cstdio> #include<cstring> #include<cc...原创 2020-03-12 11:38:10 · 225 阅读 · 1 评论 -
A1048 Find Coins (25分)
#include<iostream>#include<cstdio> #include<cstring> #include<cctype>//里面有isdigit():数字字符返回true using namespace std; int main(){int n,pay;scanf("%d %d",&n,&pay...原创 2020-03-07 12:43:19 · 139 阅读 · 0 评论 -
1050 String Subtraction (20分)
#include<iostream>#include<cstdio> #include<cstring> #include<cctype>//里面有isdigit():数字字符返回true using namespace std; int main(){string a,b;getline(cin,a);getline(cin,...原创 2020-03-07 11:26:58 · 87 阅读 · 0 评论 -
B1042 字符统计 (20分)
#include<iostream>#include<cstdio> #include<cstring> #include<cctype>//里面有isdigit():数字字符返回true using namespace std; int count[30];//只保留小写英文字母的个数 int maxn=1010;//统计时不区分...原创 2020-03-07 10:11:39 · 200 阅读 · 0 评论 -
B1033 旧键盘打字 (20分)
#include<iostream>#include<cstdio> #include<cstring> #include<cctype>//里面有isdigit():数字字符返回true using namespace std; int maxn=100010;int main(){ char str[maxn]; cin.ge...原创 2020-03-07 09:45:21 · 122 阅读 · 0 评论 -
B1029 旧键盘 (20分)
打代码的时候对比了一下晴神和柳神的写法发现晴神的代码里面对这题的解法是先把两个字符串中的小写字符都改成大写字符接着进行比较,最后输出而柳神则使用了字符串中的find函数,而find函数并没有区分大小写,也就是说在刚开始两个字符串比较的时候是区分大小写的??还是说???这样会导致操作s1="A",而s2="B";的时候产生区别我试了一下开始不转换的注意:gets不可用,...原创 2020-03-04 10:26:03 · 244 阅读 · 0 评论 -
A1080 Graduate Admission (30分)
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include<map>#include<vector>#includ...原创 2020-02-09 11:40:25 · 200 阅读 · 2 评论 -
A1083 List Grades (25分)
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include<map>#include<vector>#includ...原创 2020-02-08 23:04:02 · 114 阅读 · 0 评论 -
A1077 Kuchiguse (20分)
1.cin.getline()函数是处理数组字符串的,其原型为cin.getline(char * , int),第一个参数为一个char指针,第二个参数为数组字符串长度。2.getline(cin,str)函数是处理string类的函数。第二个参数为string类型的变量。3.在执行getline(cin,str)之前,还需要输入一个int的变量,这时候scanf(“%d\n”,&...原创 2020-02-03 19:33:49 · 162 阅读 · 0 评论 -
1001 A+B Format (20分)
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include<map>#include<vector>#includ...原创 2020-02-03 16:13:27 · 105 阅读 · 0 评论 -
B1048 数字加密 (20分)
不知道为啥部分正确?先记录一下#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include<map>#include<v...原创 2020-02-03 15:36:31 · 157 阅读 · 0 评论 -
B1024 科学计数法 (20分)
果然A1073(和B1024一样)的题难,还是细节问题一题自己写写了一小时多#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include...原创 2020-02-02 22:37:23 · 210 阅读 · 0 评论 -
B1014 福尔摩斯的约会 (20分)
这道题的细节真的是多到爆炸!写的有点乱,注意点全在代码上了主要学到了<cctype>里的两个函数isdigit()和isalpha();可以快速判断输入的字符是数字还是英文字母顺便还重新看了for循环中表达式的执行顺序,外加break之后i++不会再执行果然基础还是得扎实#include<iostream>#include<stdio.h>...原创 2020-02-02 21:22:02 · 313 阅读 · 0 评论 -
B1031 查验身份证 (15分)
1.局部变量和存放函数调用关系的栈帧(可忽略)一起存放在调用栈里,这个空间是有限的,因为栈帧的关系如果局部变量过大将会导致栈溢出错误。全局变量有专门存放的段(data段和bss段)。所以一般比较大的数组都作为全局变量放在main外面。参考柳神代码和晴神代码#include<iostream>#include<stdio.h>#include<stdl...原创 2020-02-02 15:47:56 · 165 阅读 · 0 评论 -
B1021 个位数统计 (15分)
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include<map>#include<vector>#includ...原创 2020-02-02 15:13:08 · 156 阅读 · 0 评论 -
1058 A+B in Hogwarts (20分)
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include<map>#include<vector>#includ...原创 2020-02-01 23:33:34 · 150 阅读 · 0 评论 -
pta乙级B1027
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<algorithm> #include<map>#include<vector>#includ...原创 2020-02-01 16:06:30 · 144 阅读 · 0 评论