
PAT甲级
Wayward:)
此人貌似不太懒,写了点东西~
展开
-
(PAT Advanced)1001.A+B Format(字符串处理) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problemsCalculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there a...原创 2019-03-17 21:27:09 · 276 阅读 · 0 评论 -
(PAT Advanced) 1048.Find Coins (哈希映射,二分查找)
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805432256675840题目大意假设你有N个货币,面值从1到500不等,只允许使用其中的两枚货币,然后刚好达到付款要求,如果存在多组方案,输出其中一个货币最小的方案。如果没有符合要求的方案,输出No Solution。方法1(二分查找)先对输入的N个货币...原创 2019-09-01 17:13:19 · 265 阅读 · 0 评论 -
(PAT Advanced)1053.Path of Equal Weight (树的遍历) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805424153280512Sample Input:20 9 2410 2 4 3 5 10 2 18 9 7 2 2 1 3 12 1 8 6 2 200 4 01 02 03 0402 1 0504 2 06 0703 3 11 12 1306...原创 2019-09-02 15:37:34 · 230 阅读 · 0 评论 -
(* PAT Advanced)1026.Table Tennis (队列模拟,结构体排序) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805472333250560Sample Input:920:52:00 10 008:00:00 20 008:02:00 30 020:51:00 10 008:10:00 5 008:12:00 10 120:50:00 10 008:01...原创 2019-09-02 21:56:22 · 268 阅读 · 0 评论 -
(PAT Advanced)1049.Counting Ones (数学问题,排列组合) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805430595731456题目大意一道有意思的数学题,给出一个数字n,给出所有小于等于这个数的数字中1的个数和。题目分析判断所有[1,n][1,n][1,n]的数字中1的个数,我们可以每位单独判断,计算每一位为1时有多少种情况,然后对所有情况进行求和。每一...原创 2019-09-03 11:24:17 · 314 阅读 · 0 评论 -
(PAT Advanced)1055.The World's Richest (结构体排序)
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805421066272768Sample Input:12 4Zoe_Bill 35 2333Bob_Volk 24 5888Anny_Cin 95 999999Williams 30 -22Cindy 76 76000Alice 18 88888...原创 2019-09-03 12:32:31 · 340 阅读 · 0 评论 -
(PAT Advanced) 1056.Mice and Rice (队列的使用——比赛晋级淘汰模拟) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805419468242944题目大意np为老鼠的体重,ng为每组最多的老鼠数量,给出每个老鼠的体重,和初始顺序。然后每ng个老鼠为一组,挑选每组中体重最大的老鼠晋级下一轮,然后剩下的未晋级的老鼠给予相同评级,即若当前晋级group只老鼠,则剩下老鼠的评级统一为g...原创 2019-09-03 19:44:05 · 317 阅读 · 0 评论 -
(PAT Advanced)1057 Stack(树状数组+二分查找) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805417945710592Sample Input:17PopPeekMedianPush 3PeekMedianPush 2PeekMedianPush 1PeekMedianPopPopPush 5Push 4PeekMedian...原创 2019-09-04 19:28:53 · 270 阅读 · 0 评论 -
(PAT Advanced)1059 Prime Factors (整数的素因子分解) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805415005503488题目大意将一个大整数分解成多个质数的乘积,具体请搜索数论——正整数的唯一分解定理。解法1(素数筛选和匹配)筛选法的思路是建议一个大小为maxn的素数表,假定初始全是素数,然后逐个划掉,即1不是素数,花掉;2是素数,则所有2的倍速均...原创 2019-09-04 21:14:45 · 460 阅读 · 0 评论 -
(PAT Advanced)1060.Are They Equal (字符串处理+科学计数法) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805413520719872题目大意给定计算机的有效数字N,和两个浮点数,将浮点数转成科学计数法表示,超出有效数字的部分直接截掉。题目分析用字符串或字符数组存储浮点数,先确定指数的大小:搜索小数点的位置dot,如果不存在小数点,则dot = 字符串的长度...原创 2019-09-05 11:26:07 · 263 阅读 · 0 评论 -
(PAT Advance)1063.Set Similarity (集合+交并比) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805409175420928题目大意给出多个集合元素,求任意两个集合的相似度,即交并比:两个集合的交集元素个数/两个集合的并集元素个数。方法1(暴力模拟+最后一个测试点超时)由于C++中Set数据结构即为我们常见的集合,满足不重复,且会自动排序,底部存储为红...原创 2019-09-06 11:58:13 · 377 阅读 · 0 评论 -
(PAT Advanced)1045.Favorite Color Stripe (最长子序列问题) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805437411475456题目大意给出M中喜欢的颜色(有先后顺序),然后给出一串长度为L的颜色条,去掉其中不喜欢的颜色,然后求剩下序列的一个子序列,使得这个子序列得颜色顺序符合自己喜欢颜色得先后顺序,不一定所有喜欢得颜色都有,但是要保证长度尽可能地长。方法1...原创 2019-08-31 17:20:48 · 294 阅读 · 0 评论 -
(PTA Advanced)1044.Shopping in Mars (区间查找,二分查找)
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805439202443264Sample Input 1:16 153 2 1 5 4 6 8 7 16 10 15 11 9 12 14 13Sample Output 1:1-54-67-811-11Sample Input 2:5 132...原创 2019-08-31 15:34:49 · 325 阅读 · 0 评论 -
(PAT Advanced Level) 1002.A+B for Polynomials(多项式模拟) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000This time, you are supposed to find A+B where A and B are two polynomials.Input Specification:Each input file contain...原创 2019-03-25 15:07:57 · 300 阅读 · 0 评论 -
(PAT Advanced)1004.Counting Leaves(叶节点计数——树的遍历) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805521431773184A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child...原创 2019-08-23 17:16:54 · 242 阅读 · 0 评论 -
(PAT Advanced) 1005.Spell It Right(字符串处理) C++
原题:https://pintia.cn/problemsets/994805342720868352/problems/994805519074574336Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the su...原创 2019-08-23 17:18:24 · 287 阅读 · 0 评论 -
(PAT Advanced) 1020.Tree Traversals (二叉树的后序中序转前序) C++
原题:https://pintia.cn/problemsets/994805342720868352/problems/994805519074574336Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal seq...原创 2019-08-23 17:17:52 · 252 阅读 · 0 评论 -
(PAT Advanced)1030.Travel Plan (迪杰斯特拉算法+DFS) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805464397627392 A traveler’s map gives the distances between cities along the highways, together with the cost of each highway. Now yo...原创 2019-08-23 17:03:02 · 267 阅读 · 0 评论 -
(PAT Advanced)1021.Deepest Root (树的连通性和深度) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805482919673856 A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. ...原创 2019-08-23 17:17:39 · 227 阅读 · 0 评论 -
(PTA Advanced) 1022 Digital Library (STL的应用,存储以及查询) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805480801550336A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts,...原创 2019-08-23 17:17:25 · 249 阅读 · 0 评论 -
(PAT Advanced)1031.Hello World for U (数学规律) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805462535356416Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworl...原创 2019-08-23 17:17:13 · 275 阅读 · 0 评论 -
(PAT Advanced)1040.Longest Symmetric String (字符串+动态规划) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805446102073344Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&am...原创 2019-08-29 20:39:57 · 326 阅读 · 0 评论 -
(PTA Advaced)1043.Is It a Binary Search Tree (二叉搜索树,树的遍历) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805440976633856A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtr...原创 2019-08-30 21:49:50 · 334 阅读 · 0 评论 -
(PAT Advanced) 1065 A+B and C (64bit) (迷惑的小明+整数溢出判断) C++
原题:https://pintia.cn/problem-sets/994805342720868352/problems/994805406352654336题目大意题目不难,主要输入3个数,A,B,C,然后判断A+B是否大于C,但是主要整数的范围是[−263,263][-2^{63},2^{63}][−263,263],若以若用long int存储,则可能会超出表示范围,具体可参照 计算...原创 2019-09-06 15:01:04 · 365 阅读 · 1 评论