PTA
点点滴滴25
菜鸡
展开
-
1151 LCA in a Binary Tree (30分) 测试点 2
1151 LCA in a Binary Tree (30分)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.Given any two nodes in a binary tree, you are supposed to find their LCA.Input Specification:Ea.原创 2020-07-13 18:00:26 · 549 阅读 · 0 评论 -
1034 Head of a Gang (30分) 并查集
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 between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all .原创 2020-06-28 12:53:59 · 377 阅读 · 0 评论 -
1140 Look-and-say Sequence (20分) 模拟题 我的代码+别人的快慢指针法
1140 Look-and-say Sequence (20分)Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number. For example, th原创 2020-06-18 11:57:10 · 200 阅读 · 0 评论 -
1132 Cut Integer (20分) &&的特性
1132 Cut Integer (20分)Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting to see that Z can be devided by原创 2020-06-16 22:13:50 · 226 阅读 · 0 评论 -
1128 N Queens Puzzle (20分) N皇后 问题
1128 N Queens Puzzle (20分)The "eight queens puzzle" is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal. The eig原创 2020-06-16 21:17:27 · 389 阅读 · 0 评论 -
节省运行时间的小技巧 (持续更新)
目录1.想用string,但是cin输入太费时间了,如何解决?2.去掉没用头文件1.想用string,但是cin输入太费时间了,如何解决?c++ 的cin和cout太费时间了,scanf又读不如string。一种解决方法是:下图这样map<string,XXX> 的string 可以用char 数组替换,我第一次遇见ps:unorder_map不用排序...原创 2020-05-02 22:54:54 · 918 阅读 · 0 评论 -
1059 Prime Factors (25分) + 1096 Consecutive Factors (20分)
1059 Prime Factors (25分)Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1k1×p2k2×⋯×pmkm.Input Specific...原创 2020-02-17 14:37:56 · 176 阅读 · 0 评论 -
1078 Hashing (25分) 哈希表 教训
1078 Hashing (25分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined t...原创 2020-02-16 11:29:47 · 381 阅读 · 0 评论 -
1023 Have Fun with Numbers (20分)+1024 Palindromic Number (25分) 两道大数题
两道大数题目录1023 Have Fun with Numbers (20分)Input Specification:Output Specification:Sample Input:Sample Output:1024 Palindromic Number (25分)Input Specification:Output Specification:Sam...原创 2020-02-15 13:45:27 · 370 阅读 · 0 评论 -
1017 Queueing at Bank (25分) 模拟题
1017 Queueing at Bank (25分)Suppose a bank has K windows 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...原创 2020-02-14 12:16:35 · 256 阅读 · 0 评论 -
1045 Favorite Color Stripe (30分) LIS 段错误、运行超时, 涨知识了
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 pie...原创 2020-02-11 11:49:11 · 330 阅读 · 0 评论 -
1072 Gas Station (30分) PAT 甲级
1072 Gas Station (30分)A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must gu...原创 2020-02-09 12:53:35 · 336 阅读 · 0 评论 -
1091 Acute Stroke (30分) 最后两个测试点报错
1091 Acute Stroke (30分)One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MR...原创 2020-01-14 17:39:27 · 641 阅读 · 0 评论 -
1103 Integer Factorization (30分) dfs 基础题
1103 Integer Factorization (30分)The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K−P f...原创 2020-01-11 19:20:49 · 353 阅读 · 0 评论 -
1097 Deduplication on a Linked List (25分) 简单静态链表题 20minKo
1097 Deduplication on a Linked List (25分)Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, ...原创 2019-12-11 13:43:40 · 5980 阅读 · 0 评论 -
1052 Linked List Sorting (25分) 最后一个测试点遇到段错误 +别人的代码
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...原创 2019-12-11 13:18:34 · 6308 阅读 · 0 评论 -
1032 Sharing (25分) 我的代码和别人的代码
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 ...原创 2019-12-10 16:24:00 · 225 阅读 · 0 评论 -
1074 Reversing Linked List (25分) 第五个测试点:答案错误 我的代码+别人的代码
1074 Reversing Linked List (25分)Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then yo...原创 2019-12-09 21:58:40 · 1083 阅读 · 0 评论 -
1051 Pop Sequence (25分) 我的代码+别人的代码
1051 Pop Sequence (25分)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a p...原创 2019-12-08 21:52:46 · 201 阅读 · 0 评论 -
1022 Digital Library (30分) PAT 甲级 我的代码(multimap实现)和别人精简的代码 +意外收获
目录1022 Digital Library (30分)Input Specification:Output Specification:Sample Input:Sample Output:我的代码有点冗长,但是是我智慧的结晶是时候放出大佬的代码了1022 Digital Library (30分)A Digital Library contains mill...原创 2019-12-07 17:50:11 · 262 阅读 · 0 评论 -
1071 Speech Patterns (25分) 第三个测试点 + 别人的代码
1071 Speech Patterns (25分)People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patterns can h...原创 2019-12-06 16:05:10 · 931 阅读 · 0 评论 -
1054 The Dominant Color (20 分) 简单map map对值排序 将map转化为vector
1054 The Dominant Color (20 分)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 p...原创 2019-11-26 12:17:59 · 226 阅读 · 0 评论 -
1100 Mars Numbers (20 分) 我的代码+别人的代码
1100 Mars Numbers (20 分)People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars. The numbers 1 to 12 on Earth is called "jan, feb, mar, apr, may, jun, jly, aug, sep...原创 2019-11-22 22:02:40 · 158 阅读 · 0 评论 -
1063 Set Similarity (25 分) 简单set题
1063 Set Similarity (25 分)Given two sets of integers, the similarity of the sets is defined to be Nc/Nt×100%, where Nc is the number of distinct common numbers shared by the two sets, and N...原创 2019-11-21 17:23:12 · 274 阅读 · 0 评论 -
1047 Student List for Course (25 分) 最后一个测试点总超时 如何解决 我的代码+别人的代码
1047 Student List for Course (25 分)Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student na...原创 2019-11-20 13:15:26 · 486 阅读 · 0 评论 -
1039 Course List for Student (25 分) map+vector STL练习 解决第五个测试点超时
1039 Course List for Student (25 分)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 co...原创 2019-11-19 12:57:09 · 329 阅读 · 0 评论 -
1015 Reversible Primes (20 分) PAT 甲级 一定要读懂题意
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 beca...原创 2019-11-18 13:21:43 · 195 阅读 · 0 评论 -
1081 Rational Sum (20 分) PAT 甲级 我的代码+别人的代码 (意外碰到了浮点错误)
1081 Rational Sum (20 分)Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case ...原创 2019-10-24 20:46:30 · 298 阅读 · 0 评论 -
1049 Counting Ones (30 分) PAT 甲级 数1的个数
1049 Counting Ones (30 分)The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N bei...原创 2019-10-23 21:39:20 · 210 阅读 · 0 评论 -
PAT 甲级 1008 Elevator (20 分) 水题
1008 Elevator (20 分)The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified...原创 2019-10-20 12:58:38 · 210 阅读 · 0 评论 -
1104 Sum of Number Segments (20 分) 一个疑惑点
1104 Sum of Number Segments (20 分)Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segme...原创 2019-10-19 21:02:31 · 433 阅读 · 0 评论 -
PAT 甲级 1069 The Black Hole of Numbers (20 分) 我的思路+别人思路
1069 The Black Hole of Numbers (20 分)For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order...原创 2019-10-18 21:36:18 · 165 阅读 · 0 评论 -
1093 Count PAT's (25 分) 我独特的思路(30分钟Ko)+别人的代码
1093 Count PAT's (25 分)The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, an...原创 2019-10-17 21:22:53 · 197 阅读 · 0 评论 -
PAT 甲级 1101 Quick Sort (25 分) 我的思路+别人的思路
1101 Quick Sort (25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the p...原创 2019-10-16 22:21:47 · 153 阅读 · 0 评论 -
PAT 甲级 1029 Median (25 分) 我的思路(我认为很简单的思路)
1029 Median (25 分)Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9,...原创 2019-10-14 21:57:11 · 350 阅读 · 2 评论 -
PAT 甲级 1044 Shopping in Mars (25 分)
1044 Shopping in Mars (25 分)Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the cha...原创 2019-08-29 17:21:58 · 205 阅读 · 0 评论 -
PAT 甲级 散列 1084 Broken Keyboard (20 分)
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 st...原创 2019-08-06 15:40:18 · 132 阅读 · 0 评论 -
1009 Product of Polynomials (25 分) PAT甲级1009 模拟 多项式相乘 巧用STL 我的代码+别人的代码
1009Product 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...原创 2019-07-16 17:12:02 · 319 阅读 · 0 评论 -
PAT 甲级 1010 Radix (25 分) 一道很难得满分的题,很多坑, 二分
1010 Radix (25 分)Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pa...原创 2019-08-12 12:01:25 · 499 阅读 · 0 评论 -
PAT 甲级 1085 Perfect Sequence (25 分) +二分相关知识
1085 Perfect Sequence (25 分)Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum num...原创 2019-08-10 21:36:33 · 186 阅读 · 0 评论