![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pta
萧瑟1
这个作者很懒,什么都没留下…
展开
-
2020天梯赛训练2 题目整理
7-1 辗转相除法求最大公约数 (10分)题目链接:7-1 辗转相除法求最大公约数代码如下:import java.util.Scanner;public class Main { public static int gcd(int a,int b) { return b==0? a:gcd(b,a%b); } public static...原创 2020-01-21 19:07:15 · 3873 阅读 · 0 评论 -
2020天梯赛训练1 题目整理
7-1 比较大小 (10分)题目链接:7-1 比较大小代码如下:import java.util.Arrays;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ...原创 2020-01-19 16:58:11 · 1747 阅读 · 0 评论 -
2019年PAT甲级冬季考试总结
时隔一年,我又一次报名参加了PAT考试,不过这次我是抱着找份实习工作去考的,上次是抱着做炮灰的目的去考的,不过这次比上次考的还低,排名也是比上次低了很多,我感觉问题主要是出现在以下几点:1.调试程序花费的时间太多。建树的方法是存在一定的问题的,我是把整个树都存在一个数组里面,虽然简单,但也容易出问题,我就栽在了这里。2.还有就是要少用stl,有时候不需要用,用了反而超时。3.要仔细读题,因为...原创 2019-12-09 17:21:46 · 601 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1143 Lowest Common Ancestor
题目描述The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which ...原创 2019-12-04 19:48:52 · 149 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1114 Family Property (25 分)
题目描述This time, you are supposed to help us collect the data for family-owned property. Given each person’s family members, and the estate(房产)info under his/her own name, we need to know the size of e...原创 2019-12-03 19:27:59 · 276 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1033 To Fill or Not to Fill(贪心)
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different ga...原创 2019-11-22 08:43:24 · 119 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1084-1087 题解
1084 Broken Keyboard (20分)On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a strin...原创 2019-11-16 15:23:13 · 332 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分)
本来想在原来做的pta博客上再附上java实现的代码,发现这道题没写博客,那只好补发一波了,hhh题目:This time, you are supposed to findA+BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Eac...原创 2019-10-27 19:32:16 · 194 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1031 Hello World for U (20 分)
Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:h de ll rlowoThat is, the characters must be prin...原创 2018-11-29 12:52:15 · 108 阅读 · 0 评论 -
PAT (Advanced Level) Practice 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), and E - Eng...原创 2018-11-26 14:01:48 · 127 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1003 Emergency (25 分) 单源最短路变式
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 the l...原创 2018-11-26 20:46:23 · 128 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 dig...原创 2018-11-29 00:59:38 · 104 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1043 Is It a Binary Search Tree (25 分)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key. The right su...原创 2018-11-23 14:03:26 · 111 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1030 Travel Plan (30 分)单源最短路变式
A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b...原创 2018-11-17 15:21:38 · 110 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1052 Linked List Sorting (25 分)
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now give...原创 2018-11-22 23:38:45 · 146 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1118 Birds in Forest (25 分) 并查集
Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the scientists to count the maxi...原创 2018-11-19 23:21:46 · 140 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1107 Social Clusters (30 分)并查集
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A social cluster is a set of people who have some of thei...原创 2018-11-19 22:45:56 · 202 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1102 Invert a Binary Tree (25 分)树的遍历
The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off.Now it's your turn to...原创 2018-11-19 20:37:30 · 186 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1094 The Largest Generation (25 分)树的层次遍历
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.Input ...原创 2018-11-19 15:54:07 · 123 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1032 Sharing (25 分) 链表的遍历
To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...原创 2018-11-22 00:12:24 · 126 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1070 Mooncake (25 分)
Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now ...原创 2018-11-21 20:42:15 · 155 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1004 Counting Leaves (30 分)树的层次遍历
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 starts...原创 2018-11-21 19:50:14 · 127 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1054 The Dominant Color (20 分) map使用
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the d...原创 2018-11-21 00:27:20 · 153 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1045 Favorite Color Stripe (30 分) 最长递增子序列
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 parts...原创 2018-11-20 21:11:30 · 147 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1025 PAT Ranking (25 分)
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists w...原创 2018-11-29 23:29:31 · 209 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1150 Travelling Salesman Problem (25 分)
The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and retu...原创 2018-11-30 00:46:17 · 109 阅读 · 0 评论 -
2019天梯赛训练2 7-12 最长对称子串 (25 分) 暴力
对给定的字符串,本题要求你输出最长对称子串的长度。例如,给定Is PAT&TAP symmetric?,最长对称子串为s PAT&TAP s,于是你应该输出11。输入格式:输入在一行中给出长度不超过1000的非空字符串。输出格式:在一行中输出最长对称子串的长度。输入样例:Is PAT&TAP symmetric?输出样例:11 代...原创 2019-01-30 16:06:47 · 213 阅读 · 0 评论 -
2019天梯赛训练1 7-10 链表去重 (25 分)
给定一个带整数键值的链表 L,你需要把其中绝对值重复的键值结点删掉。即对每个键值 K,只有第一个绝对值等于 K 的结点被保留。同时,所有被删除的结点须被保存在另一个链表上。例如给定 L 为 21→-15→-15→-7→15,你需要输出去重后的链表 21→-15→-7,还有被删除的链表 -15→15。输入格式:输入在第一行给出 L 的第一个结点的地址和一个正整数 N(≤105,为结点总...原创 2019-01-27 12:05:32 · 3791 阅读 · 0 评论 -
2018年pat甲级冬季考试总结
今天上午12点半吃完饭后发现还有一个小时才考试,于是找了个教室睡了一觉,起来发现已经1点20了,于是马不停蹄的跑去考场,拿出身份证和准考证后慌忙的找到位置,然后梦梦悠悠的就点开了考试。。第一题看了一遍,发现就看懂一个超越数还是中文的。瞅了有五分钟,还是没看懂,旁边两个人却已经开始敲了。。。然后我想看不懂那就看第二题,一打开发现题目好长,然后就开始读题,读了十分钟吧,没大懂,然后就去读第三题,...原创 2018-12-09 20:54:42 · 1525 阅读 · 3 评论 -
PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分)
This time, you are supposed to find A+B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...原创 2018-12-07 09:54:06 · 143 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one t...原创 2018-12-07 00:45:04 · 117 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1041 Be Unique (20 分)
Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,104]. The first one who bets o...原创 2018-12-06 20:00:53 · 221 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1145 Hashing - Average Search Time (25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...原创 2018-12-06 19:28:09 · 183 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1039 Course List for Student (25 分) Hash离散化
Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes ...原创 2018-12-06 14:19:00 · 143 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1024 Palindromic Number (25 分)大数模拟
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...原创 2018-12-05 21:51:13 · 134 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1037 Magic Coupon (25 分)
The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product b...原创 2018-12-05 20:46:31 · 120 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1015 Reversible Primes (20 分)
A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pr...原创 2018-11-28 18:59:58 · 133 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...原创 2018-11-28 12:34:22 · 101 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1144 The Missing Number (20 分)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line giv...原创 2018-12-04 21:22:45 · 95 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1144 The Missing Number (20 分)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line giv...原创 2018-12-04 21:22:06 · 129 阅读 · 0 评论