随笔分类 -  PAT (Basic Level) Practice

本人刷PAT乙级的记录
摘要:1017 A除以B (20分) orz柳诺小姐姐的代码 //模拟手动除法的过程,每次用第一位去除以B,如果得到的商不是0就输出,否则就*10+下一位,直到最后的数为余数~ #include <iostream> using namespace std; int main() { string s; 阅读全文
posted @ 2020-06-18 08:52 chstor 阅读(222) 评论(0) 推荐(0)
摘要:1013 数素数 (20分) 测试点4就是素数可能超出10000这个大小,所以设置大点,例如:105000 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstrea 阅读全文
posted @ 2020-06-17 08:17 chstor 阅读(149) 评论(0) 推荐(0)
摘要:1007 素数对猜想 (20分) 注意这个条件 i+2<=n ,不然会超出范围 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #include<st 阅读全文
posted @ 2020-06-17 08:14 chstor 阅读(103) 评论(0) 推荐(0)
摘要:1003 我要通过! (20分) 得出重要结论:p*(t-p-1)==s.length()-1-t #include<iostream> #include<map> using namespace std; int main(){ int n;cin>>n; while(n--){ int t=0, 阅读全文
posted @ 2020-06-16 06:56 chstor 阅读(140) 评论(0) 推荐(0)
摘要:1049 数列的片段和 (20分) #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #include<string> #include<cstdio> 阅读全文
posted @ 2020-06-15 13:37 chstor 阅读(148) 评论(0) 推荐(0)
摘要:1019 数字黑洞 (20分) 一个字符串的写法,坑点就是可能会出现不到4位的数,进行补零 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #incl 阅读全文
posted @ 2020-06-15 13:36 chstor 阅读(258) 评论(0) 推荐(0)
摘要:1035 插入与归并 (25分) 数据比较小,归并不用写合并函数,直接sort 中间序列不包括初始序列 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> 阅读全文
posted @ 2020-06-15 08:14 chstor 阅读(91) 评论(0) 推荐(0)
摘要:1045 快速排序 (25分) 求划分的主元(比左边的都大,右边的都小) #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #include<strin 阅读全文
posted @ 2020-06-14 08:53 chstor 阅读(144) 评论(0) 推荐(0)
摘要:1040 有几个PAT (25分) 和1045快排那个思想很像 左边、右边的分别累加在数组中存入 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #i 阅读全文
posted @ 2020-06-14 08:51 chstor 阅读(147) 评论(0) 推荐(0)
摘要:1030 完美数列 (25分) 二分查找常用函数: lower_bound() 函数用于在指定区域内查找不小于目标值的第一个元素 upper_bound() 函数定义在头文件中,用于在指定范围内查找大于目标值的第一个元素 第一次写的代码,测试点4没过 下面举个例子,如数组:1,2,3,4,5,6,7 阅读全文
posted @ 2020-06-13 08:49 chstor 阅读(182) 评论(0) 推荐(0)
摘要:1020 月饼 (25分) 把单价先计算一下,然后按照单价高依次出售 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #include<string> 阅读全文
posted @ 2020-06-12 09:40 chstor 阅读(123) 评论(0) 推荐(0)
摘要:1023 组个最小数 (20分) -做完散列感觉这个好像散列,算法笔记把它分在了贪心emmm #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #inc 阅读全文
posted @ 2020-06-12 09:39 chstor 阅读(119) 评论(0) 推荐(0)
摘要:1005 继续(3n+1)猜想 (25分) 输入的数列里面,输出“关键数”(没被覆盖的) 标记一下n往后的就可以了,标记的是覆盖的 eg:{3、5、8、4、2、1},标记{5、8、4、2} #include<iostream> #include<vector> #include<cctype> #i 阅读全文
posted @ 2020-06-11 19:34 chstor 阅读(103) 评论(0) 推荐(0)
摘要:#include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #include<string> #include<cstdio> #include<algorith 阅读全文
posted @ 2020-06-11 19:31 chstor 阅读(118) 评论(0) 推荐(0)
摘要:1043 输出PATest (20分) 注意控制已有字符的输出 存放的输出了就减一,存放个数必须大于零 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> 阅读全文
posted @ 2020-06-11 19:29 chstor 阅读(198) 评论(0) 推荐(0)
摘要:1042 字符统计 (20分) 本题只让输出小写字母 小写字母转换为数字0~25 输出的时候再转换回来 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> 阅读全文
posted @ 2020-06-11 19:25 chstor 阅读(97) 评论(0) 推荐(0)
摘要:1039 到底买不买 (20分) 甲级也有一样的题 #include<iostream> #include<vector> #include<cctype> #include<algorithm> #include<sstream> #include<string> #include<cstdio> 阅读全文
posted @ 2020-06-11 19:24 chstor 阅读(84) 评论(0) 推荐(0)
摘要:1038 统计同成绩学生 (20分) #include<iostream> #include<vector> #include<cctype> #include<algorithm> #include<sstream> #include<string> #include<cstdio> const 阅读全文
posted @ 2020-06-11 19:22 chstor 阅读(113) 评论(0) 推荐(0)
摘要:测试点2有个坑就是不能用cin来输入字符 题目保证第二行输入非空,第一行可能是空,cin读不了空字符 #include<iostream> #include<vector> #include<cctype> #include<algorithm> #include<sstream> #include 阅读全文
posted @ 2020-06-11 08:27 chstor 阅读(103) 评论(0) 推荐(0)
摘要:1029 旧键盘 (20分) 用str【200】来标记已经输出的字符,散列查找 #include<iostream> #include<vector> #include<ctype.h> #include<algorithm> #include<sstream> #include<string> # 阅读全文
posted @ 2020-06-11 08:24 chstor 阅读(116) 评论(0) 推荐(0)