PTA甲级
文章平均质量分 87
新西兰做的饭
Here we go!
展开
-
PTA-最短路径(1003/1018/1030/1072/1087)
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 length of each road between any pai原创 2022-03-04 19:24:35 · 952 阅读 · 0 评论 -
PTA-链表处理(1074/1032/1052/1097)
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 you must output 3→2→1→6→5→4; if K=4, you must output 4→3→2原创 2022-02-24 11:31:41 · 739 阅读 · 0 评论 -
PTA-平衡二叉树(1066)
1066 Root of AVL Tree (25 分)An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this prope原创 2022-02-07 12:00:35 · 481 阅读 · 0 评论 -
PTA-二叉查找树(1043/1064/1099)
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 subtree of a node co.原创 2022-02-06 18:42:14 · 893 阅读 · 0 评论 -
PTA-树的遍历(1079/1090/1094/1106/1004/1053)
1079 Total Sales of Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys pro.原创 2022-01-22 15:45:35 · 979 阅读 · 0 评论 -
PTA-二叉树的遍历(1020/1086/1102)
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 the corresponding binary tree.Inpu原创 2022-01-19 15:56:01 · 1467 阅读 · 0 评论 -
PTA-BFS(1091)
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 MRI slice, your job is to calculate the volume of the stro原创 2022-01-16 11:10:07 · 375 阅读 · 0 评论 -
PTA-链表处理(1074)
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 you must output 3→2→1→6→5→4; if K=4, you must output 4→3→2原创 2022-01-15 20:57:36 · 307 阅读 · 0 评论 -
PTA-DFS(1103)
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 factorization of N for any positive integers N, K and P.原创 2022-01-15 18:09:40 · 373 阅读 · 0 评论 -
PTA-queue(1056)
1056 Mice and Rice (25 分)Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice as possible in order to beco.原创 2022-01-14 12:04:33 · 245 阅读 · 0 评论 -
PTA-stack(1051)
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 possible pop sequence of the stack. For example, if M is 5.原创 2022-01-12 17:13:33 · 587 阅读 · 0 评论 -
PTA-map(1100/1054/1071/1022)
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, oct, nov, dec” on Mars, respectively.For the next highe.原创 2022-01-12 11:39:18 · 426 阅读 · 0 评论 -
PTA-string(1060)
Are They Equal (25 分)If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×10 5with simple chopping. Now given the number of significant digits on a machine and two fl.原创 2022-01-11 10:41:22 · 385 阅读 · 0 评论 -
PTA-set(1063)
1063 Set Similarity (25 分)Given two sets of integers, the similarity of the sets is defined to be Nc/Nt×100%, where N cis the number of distinct common numbers shared by the two sets, and N tis the total number of distinct numbers in the two sets. Your j.原创 2022-01-10 18:34:31 · 406 阅读 · 0 评论 -
PTA-vector(1047/1039)
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 name lists of all the courses.Input Specification:Each i.原创 2022-01-10 16:43:34 · 584 阅读 · 0 评论 -
PTA-双指针(1029/1044)
双指针系列两道题总结分析原创 2021-12-29 00:47:18 · 332 阅读 · 1 评论 -
PTA-数学问题(1069/1104/1008/1049/1081/1088/1015/1078/1096/1059/1023/1024)
PTA-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, a new number can be obtained by taking the second .原创 2021-08-21 16:51:21 · 452 阅读 · 0 评论 -
PTA-二分(1085/1010/1044/1048)
PTA-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 numbers in the sequence, respectively.Now given a sequ.原创 2021-08-07 14:37:16 · 248 阅读 · 0 评论 -
PTA-贪心(1070/1033/1037/1067/1038)
PTA-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 given the inventory amounts an.原创 2021-07-30 17:23:52 · 291 阅读 · 0 评论 -
PTA-散列(1084/1092/1041/1050/1048)
PTA-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 string that you are supposed to type, and the string th.原创 2021-07-25 16:28:36 · 165 阅读 · 0 评论 -
PTA-字符串处理(1061/1073/1001/1005/1035/1077/1082)
PTA-1061 Dating (20 分)Sherlock Holmes received a note with some strange strings: Let’s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those strange strings are actually referring to the c.原创 2021-07-19 14:16:29 · 317 阅读 · 1 评论 -
PTA-进制转换(1019/1027/1058)
PTA1019A 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.Although palindromic numbers are most often c.原创 2021-07-16 11:23:03 · 1862 阅读 · 0 评论 -
PTA-1030 Travel Pla(使用堆优化的dijkstra算法)
PTA-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 between his/her starting cit.原创 2021-05-31 20:39:42 · 167 阅读 · 0 评论 -
PTA-1114 Family Property(并查集)
PTA-1114 Family PropertyThis 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 each family, and the average area and原创 2021-05-31 19:30:53 · 131 阅读 · 0 评论 -
PTA-1118 Birds in Forest(并查集)
PTA-1118 Birds in ForestSome 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 maximum number of trees in the fore原创 2021-05-28 19:17:09 · 139 阅读 · 0 评论 -
PTA-1107 Social Clusters(并查集)
PTA1107-Social ClustersWhen 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 their hobbies in common. You are sup原创 2021-05-27 20:30:33 · 107 阅读 · 0 评论 -
PTA-1003 Emergency(使用堆优化的dijkstra算法)
#include<bits/stdc++.h>using namespace std;#define INF 0x3f3f3f3fconst int maxx=505;struct edge{ int to,dis,cost; edge(int _to,int _dis,int _cost){to=_to,dis=_dis,cost=_cost;}};vector<edge> a[maxx];typedef pair<int ,int> P;int原创 2021-05-25 19:38:26 · 160 阅读 · 0 评论 -
PTA1008
PTA1008 Elevator问题描述: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 order. It costs 6 seconds to move the elevator up one原创 2020-11-29 08:41:49 · 168 阅读 · 0 评论 -
PTA1006
PTA1006 Sign In and Sign Out问题描述: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, you are supposed to find原创 2020-11-15 09:23:56 · 195 阅读 · 0 评论 -
PTA1005
PTA1005问题描述:Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Each case occupies one line which contains an N原创 2020-11-14 21:33:25 · 146 阅读 · 0 评论 -
PTA1002
PTA1002问题描述: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 information of a polynomial:K N1 aN1 N2 aN2 …原创 2020-11-14 20:26:54 · 135 阅读 · 0 评论 -
PTA1001
PTA1001问题描述:Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specification:Each input file contains one test case. Each case contai原创 2020-11-14 20:07:45 · 206 阅读 · 0 评论