
PAT
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
【PAT甲级最新题解】PAT甲级2020.7月春季考试满分题解(附代码)
写在前面:这次题目虽然大多数是模拟题且不算难,但是题面其实不算友好,不少同学因为题目描述而错失满分。A:题意:给定一个数字串,问每一个前缀串是否是素数。模拟题不多解释。#include<cstdio>#include<algorithm>#include<cstring>#include<stack>#include<queue>#include<string>#include<iostream&..原创 2020-08-02 16:41:40 · 859 阅读 · 0 评论 -
【PAT甲级 - 1028】List Sorting (25分)(模拟,排序)
题干:Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contain...原创 2020-02-07 16:14:08 · 232 阅读 · 0 评论 -
【PAT - 甲级1024】Palindromic Number (25分)(大数,模拟)
题干:A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic nu...原创 2020-02-06 23:11:21 · 212 阅读 · 0 评论 -
【PAT - 甲级1021】Deepest Root (25分)(并查集,暴力枚举)
题干:A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a ...原创 2020-02-05 23:25:04 · 4555 阅读 · 0 评论 -
【PAT - 甲级1020】Tree Traversals (25分)(树的遍历,给定中序后序,求层次遍历)
题干:Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of th...原创 2020-02-05 23:03:04 · 223 阅读 · 0 评论 -
【PAT - 甲级1017】Queueing at Bank (25分)(优先队列,模拟)
题干:Suppose a bank hasKwindows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yell...原创 2020-02-05 17:56:41 · 250 阅读 · 0 评论 -
【PAT甲级 - 1013】Battle Over Cities (25分)(并查集)
题干:It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if w...原创 2020-02-05 16:21:12 · 249 阅读 · 0 评论 -
【PAT - 甲级1012】The Best Rank (25分)
题干:To evaluate the performance of our first year CS majored students, we consider their grades of three courses only:C- C Programming Language,M- Mathematics (Calculus or Linear Algrbra), andE...原创 2020-02-05 15:49:31 · 203 阅读 · 0 评论 -
【PAT - 甲级1010】Radix (25分)(二分,进制转化)
题干:Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer isyes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive...原创 2020-02-05 12:35:56 · 360 阅读 · 0 评论 -
【PAT - 甲级1009】Product of Polynomials (25分)(模拟,细节)
题干:This time, you are supposed to findA×BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the in...原创 2020-02-04 14:48:10 · 307 阅读 · 0 评论 -
【PAT - 甲级1006】Sign In and Sign Out (25分)(STLmap)
题干:At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's...原创 2020-02-03 22:49:38 · 230 阅读 · 0 评论 -
【PAT - 甲级1003】Emergency (25分)(Dijkstra,最短路条数,双权值最短路)
题干:As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and ...原创 2020-02-03 22:41:21 · 291 阅读 · 0 评论 -
【PAT - 甲级1155】Heap Paths (30分)(栈,dfs,二叉树)
题干:In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal ...原创 2020-02-03 11:59:33 · 183 阅读 · 0 评论 -
【PAT - 甲级1095】Cars on Campus (30分)(模拟)
题干:Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, ...原创 2020-02-02 16:48:22 · 275 阅读 · 0 评论 -
【PAT - 甲级1007】Maximum Subsequence Sum (25分)(前缀和)
题干:Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subs...原创 2020-02-02 12:29:55 · 311 阅读 · 0 评论 -
【PAT - 甲级1094】The Largest Generation (25分)(dfs建树)
题干:A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.I...原创 2020-02-01 20:59:06 · 6149 阅读 · 0 评论 -
【PAT - 甲级1034】Head of a Gang (30分)(并查集)
题干:One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight of a relation is defined to...原创 2020-02-01 16:57:48 · 328 阅读 · 0 评论 -
【PAT - 甲级1004】Counting Leaves (30分) (dfs,递归)
题干:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case s...原创 2020-01-31 14:23:41 · 234 阅读 · 0 评论 -
【PAT - 甲级1005】Spell It Right (20分) (递归输出,水题)
题干:Given a non-negative integerN, your task is to compute the sum of all the digits ofN, and output every digit of the sum in English.Input Specification:Each input file contains one test case...原创 2020-01-31 13:44:40 · 203 阅读 · 0 评论 -
【PAT - 甲级1045】Favorite Color Stripe(30分)(dp,LIS类问题)
题干:Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining ...原创 2020-01-31 13:32:58 · 742 阅读 · 0 评论 -
【PAT - 甲级 - 1018】Public Bike Management (带权最短路,多条最短路中加条件,DFS)
题干:链接:https://www.nowcoder.com/questionTerminal/4b20ed271e864f06ab77a984e71c090f来源:牛客网There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over...原创 2018-10-10 16:04:19 · 465 阅读 · 0 评论 -
*【PAT天梯】分而治之(并查集,暴力)
题干:L2-1分而治之(25 分)分而治之,各个击破是兵家常用的策略之一。在战争中,我们希望首先攻下敌方的部分城市,使其剩余的城市变成孤立无援,然后再分头各个击破。为此参谋部提供了若干打击方案。本题就请你编写程序,判断每个方案的可行性。输入格式:输入在第一行给出两个正整数 N 和 M(均不超过10 000),分别为敌方城市个数(于是默认城市从 1 到 N 编号)和连接两城市的通...原创 2019-03-09 17:33:48 · 354 阅读 · 1 评论 -
【PAT天梯】【L2-2 小字辈(左子右兄加强版)】(树,水题)
题干:L2-2小字辈(左子右兄加强版)(25 分)本题给定一个庞大家族的家谱,要请你给出最小一辈的名单。需要注意的是,家族成员的输入方式,是按照“Left-child Right-sibling”(左儿子 右兄弟)的格式【敲黑板】sibling的意思是兄弟/姐妹,是亲兄弟,不是“表兄弟”!2019年春季PAT中不认识单词sibling的孩纸请牢记……注:本题是在浙江大学陈越老师的G...原创 2019-03-09 17:36:09 · 1131 阅读 · 0 评论 -
【PTA天梯赛CCCC -2017决赛L1-6 】整除光棍 (20 分)(大数模拟除法)
题干:这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1、11、111、1111等。传说任何一个光棍都能被一个不以5结尾的奇数整除。比如,111111就可以被13整除。 现在,你的程序要读入一个整数x,这个整数一定是奇数并且不以5结尾。然后,经过计算,输出两个数字:第一个数字s,表示x乘以s是一个光棍,第二个数字n是这个光棍的位数。这样的解当然不是唯一的,题目要求你输出最...原创 2019-03-21 14:26:13 · 263 阅读 · 0 评论 -
【PTA天梯赛CCCC -2017决赛L2-3】图着色问题 (25 分)(图染色)
题干:L2-3图着色问题(25分)图着色问题是一个著名的NP完全问题。给定无向图G=(V,E),问可否用K种颜色为V中的每一个顶点分配一种颜色,使得不会有两个相邻顶点具有同一种颜色?但本题并不是要你解决这个着色问题,而是对给定的一种颜色分配,请你判断这是否是图着色问题的一个解。输入格式:输入在第一行给出3个整数V(0<V≤500)、E(≥0)和K(0<K≤V)...原创 2019-03-21 14:31:01 · 659 阅读 · 0 评论 -
【PTA天梯赛CCCC -2017决赛L2-4】部落 (25 分)(图染色)
题干:在一个社区里,每个人都有自己的小圈子,还可能同时属于很多不同的朋友圈。我们认为朋友的朋友都算在一个部落里,于是要请你统计一下,在一个给定社区中,到底有多少个互不相交的部落?并且检查任意两个人是否属于同一个部落。输入格式:输入在第一行给出一个正整数N(≤104),是已知小圈子的个数。随后N行,每行按下列格式给出一个小圈子里的人:KP[1]P[2]⋯P[K]其中...原创 2019-03-21 14:32:20 · 337 阅读 · 0 评论 -
【PAT - 1014】福尔摩斯的约会(简单模拟)
题干:大侦探福尔摩斯接到一张奇怪的字条:“我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm”。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间“星期四 14:04”,因为前面两字符串中第1对相同的大写英文字母(大小写有区分)是第4个字母'D',代表星期四;第2对相同的字符是'E',那是第5个英文字...原创 2018-08-27 15:50:37 · 404 阅读 · 0 评论